• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Http.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.Http.User的典型用法代码示例。如果您正苦于以下问题:C# User类的具体用法?C# User怎么用?C# User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



User类属于System.Web.Http命名空间,在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Post

        // POST odata/User
        public virtual async Task<IHttpActionResult> Post(User user)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                await MainUnitOfWork.InsertAsync(user);
            }
            catch (DbUpdateException)
            {
                if (MainUnitOfWork.Exists(user.Id))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return Created(user);
        }
开发者ID:gitter-badger,项目名称:WealthEconomy,代码行数:26,代码来源:UsersController.cs


示例2: GetUserByUserName

        public object GetUserByUserName(string userName)
        {
            //logger.Debug("Start");
            User user = new User();

            try
            {
                if (String.IsNullOrEmpty(userName))
                {
                    throw new HttpResponseException(HttpStatusCode.BadRequest);
                }
                else
                {
                    user = _ldapService.GetUserByUserName(userName);
                }

            }
            catch (Exception e)
            {

                logger.ErrorException("Exception", e);
            }

            return user;
        }
开发者ID:patrickwensel,项目名称:WS,代码行数:25,代码来源:LDAPController.cs


示例3: BuildShip

        /// <summary>
        /// Builds new Ship from preset, user, and cellTypes
        /// </summary>
        /// <param name="owner">User, who owns the Ship</param>
        /// <param name="preset">Ship preset</param>
        /// <param name="cellTypes">cellTypes[i] - type of room with id = i</param>
        /// <returns>Built Ship</returns>
        public Ship BuildShip(User owner, ShipPreset preset, IEnumerable<int> cellTypes)
        {
            Ship ship = new Ship(owner, preset.RoomIds.GetLength(1), preset.RoomIds.GetLength(0));
            ship.preset = preset;

            currentWeaponId = 0;
            assignedWeaponIds = new Dictionary<int, int>();

            for (int i = 0; i < ship.cells.Length; i++)
            {
                for (int j = 0; j < ship.cells[i].Length; j++)
                {
                    int roomId = preset.RoomIds[i, j];
                    ship.cells[i][j] = buildCell(ship, cellTypes.ToList()[roomId], roomId);
                    if (currentWeaponId >= preset.weapons.Length) currentWeaponId = 0;
                }
            }

            assignesStatuses = new Dictionary<int, CellStatus>();
            InitCellStatuses(ship, preset);

            if (preset.afterShipBuilt != null)
                preset.afterShipBuilt.Invoke(ship);

            return ship;
        }
开发者ID:GLAVAK,项目名称:AIGame,代码行数:33,代码来源:ShipBuilder.cs


示例4: Put

        // PUT odata/User(5)
        public virtual async Task<IHttpActionResult> Put([FromODataUri] int key, User user)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (key != user.Id)
            {
                return BadRequest();
            }

            try
            {
                await MainUnitOfWork.UpdateAsync(user);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MainUnitOfWork.Exists(key))
                {
                    return NotFound();
                }
                else
                {
                    return Conflict();
                }
            }

            return Ok(user);
        }
开发者ID:gitter-badger,项目名称:WealthEconomy,代码行数:31,代码来源:UsersController.cs


示例5: PutUser

        public IHttpActionResult PutUser(int id, User user)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != user.UserID)
            {
                return BadRequest();
            }

            db.Entry(user).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
开发者ID:jackngare,项目名称:LEproj,代码行数:32,代码来源:UsersController.cs


示例6: GetEvent

        public IHttpActionResult GetEvent(int id)
        {
            Event @event = db.Events.Find(id);
            if (@event == null)
            {
                return NotFound();
            }
            List<User> custUserList = new List<User>();
            foreach (User myUser in @event.Users)
            {
                User custUser = new User();
                custUser.address = myUser.address;
                custUser.credit = myUser.credit;
                custUser.dob = myUser.dob;
                custUser.email = myUser.email;
                custUser.emgcontact = myUser.emgcontact;
                custUser.emgrelationship = myUser.emgrelationship;
                custUser.Events = new List<Event>();
                custUser.fbtoken = myUser.fbtoken;
                custUser.gender = myUser.gender;
                custUser.geocode = myUser.geocode;
                custUser.id = myUser.id;
                custUser.ImgUrl = myUser.ImgUrl;
                custUser.name = myUser.name;
                custUser.phone = myUser.phone;
                custUser.ubertoken = myUser.ubertoken;
                custUserList.Add(custUser);

            }
            @event.Users = custUserList;
            return Ok(@event);
        }
开发者ID:seeyouu87,项目名称:HangOver,代码行数:32,代码来源:EventsController.cs


示例7: CreateUser

        public async Task<IHttpActionResult> CreateUser(UserCreationDto dto)
        {
            if (UserNameExists(dto.UserName))
            {
                return BadRequest("已存在此登录名");
            }
            //create user
            var user = new User
            {
                UserName = dto.UserName,
                DisplayName = dto.DisplayName,
                Class = dto.ClassNumber,
                Grade = dto.Grade,
                Roles = new HashSet<UserRole>()
            };

            var result = await _userManager.CreateAsync(user, dto.Password);

            if (!result.Succeeded)
            {
                return BadRequest(string.Join(" ", result.Errors));
            }

            var userId = (await _userManager.FindByNameAsync(user.UserName)).Id;

            //add to role
            dto.Roles.ToList().ForEach(rs => { _userManager.AddToRole(userId, rs); });
            return StatusCode(HttpStatusCode.Accepted);
        }
开发者ID:Zjazure,项目名称:FailureTroubleshooting,代码行数:29,代码来源:IdentityController.cs


示例8: FindUsers

        public IHttpActionResult FindUsers(string q = null, bool rq = false)
        {
            IEnumerable<User> Users = null;

            if (q == null)
            {
                Users = Lookup.Data.AllUsers();
            }
            else
            {
                Users = Lookup.Data.FindUsers(q);
            }

            if (rq)
            {
                var User = new User();
                User.Name = q;
                User.Title = "Click here if the user is not listed below.";
                User.Office = string.Empty;
                User.PhotoUrl = Properties.Settings.Default.NoPhotoImageUrl;
                Users = Users.Concat(new User[] { User });
            }

            return Ok(Users);
        }
开发者ID:GuildfordBC,项目名称:activedirectory-api,代码行数:25,代码来源:UsersController.cs


示例9: PutUser

        // PUT api/Users/5
        public HttpResponseMessage PutUser(int id, User user)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != user.Id)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            db.Entry(user).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
开发者ID:nathanfl,项目名称:AAHIPro,代码行数:26,代码来源:UsersController.cs


示例10: PostUser

        // POST api/User
        public HttpResponseMessage PostUser(User user)
        {
            if (ModelState.IsValid)
            {
                if (!db.Users.Any())
                {
                    user.UserID = 0;
                }
                else
                {
                    user.UserID = db.Users.Max(record => record.UserID) + 1;
                }

                db.Users.Add(user);
                db.SaveChanges();
                db.Configuration.ProxyCreationEnabled = false;
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, user);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = user.UserID }));
                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
开发者ID:nghia2080,项目名称:CProject,代码行数:26,代码来源:UserController.cs


示例11: GetTasksListByDate

        public static TaskListModel GetTasksListByDate(DateTime date, User currentUser)
        {
            BYEntities db = new BYEntities();
            List<Task> tempUncTasks = db.Tasks.Where(x => db.Calendars.Any(
                    y => EntityFunctions.TruncateTime(y.Date) == date
                    && x.Id == y.TaskId
                    && y.UserId == currentUser.Id
                    && y.TaskCompleted == false)).ToList();

            List<TasksModel> uncompletedTasks = new List<TasksModel>();
            foreach (Task tsk in tempUncTasks)
            {
                uncompletedTasks.Add(new TasksModel(tsk));
            }

            List<Task> tempCompTasks = db.Tasks.Where(x => db.Calendars.Any(
                y => EntityFunctions.TruncateTime(y.Date) == date
                && x.Id == y.TaskId
                && y.UserId == currentUser.Id
                && y.TaskCompleted == true)).ToList();

            List<TasksModel> completedTasks = new List<TasksModel>();
            foreach (Task tsk in tempCompTasks)
            {
                completedTasks.Add(new TasksModel(tsk));
            }
            return new TaskListModel(completedTasks, uncompletedTasks);
        }
开发者ID:keydown,项目名称:ChicksBook,代码行数:28,代码来源:TasksController.cs


示例12: Put

        // PUT odata/User(5)
        public async Task<IHttpActionResult> Put([FromODataUri] string key, User user)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (key != user.Id)
            {
                return BadRequest();
            }

            db.Entry(user).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(key))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return Updated(user);
        }
开发者ID:R4CLucky14,项目名称:UTCCatholic,代码行数:33,代码来源:UserController.cs


示例13: RegisterUser

        public async Task<HttpResponseMessage> RegisterUser(RegisterBindingModel userData)
        {
            if (!ModelState.IsValid)
            {
                return await this.BadRequest(this.ModelState).ExecuteAsync(new CancellationToken());
            }

            var user = new User
            {
                UserName = userData.Username,
                Email = userData.Email,
                Name = userData.Name
            };

            var identityResult = await this.UserManager.CreateAsync(user, userData.Password);

            if (!identityResult.Succeeded)
            {
                return await this.GetErrorResult(identityResult).ExecuteAsync(new CancellationToken());
            }

            var loginResult = this.LoginUser(new LoginBindingModel()
            {
                Username = userData.Username,
                Password = userData.Password
            });

            return await loginResult;
        }
开发者ID:antoniapavlova,项目名称:TechShop,代码行数:29,代码来源:UserController.cs


示例14: Post

 public int Post(User user)
 {
     if (user == null)
         return 0;
     if (user.Password == null)
         return 0;
     return service.SignInUser(user.Email, user.Password.Password);
 }
开发者ID:foster-hub,项目名称:box-cms,代码行数:8,代码来源:Core_SigninController.cs


示例15: UpdateUser

 public void UpdateUser(User userUpdated)
 {
     //TODO - Deal with null
     var user = GetUser(userUpdated.Id);
     user.Username = userUpdated.Username;
     user.FirstName = userUpdated.FirstName;
     user.LastName = userUpdated.LastName;
     _ctx.SaveChanges();
 }
开发者ID:ryanmcintire,项目名称:SimpleContactAPI,代码行数:9,代码来源:UserRepo.cs


示例16: ExtraModelToEntity

        protected void ExtraModelToEntity(User entity, UserModel model, ActionTypes actionType)
        {
            if (actionType == ActionTypes.Add)
            {
                entity.Password = StringHelper.GetMD5Hash(model.password);

                entity.Key = StringHelper.GetMD5Hash(String.Format("{0}_{1}", model.login, model.password));
            }
        }
开发者ID:HedinRakot,项目名称:Zierer,代码行数:9,代码来源:Custom.UserController.cs


示例17: Put

        // PUT odata/User(5)
        public override async Task<IHttpActionResult> Put([FromODataUri] int key, User user)
        {
            var currentUser = await GetCurrentUserAsync();
            var isAdmin = this.GetCurrentUserIsAdmin();
            if (user.Id != currentUser.Id && !isAdmin)
                return Unauthorized();

            return await base.Put(key, user);
        }
开发者ID:gitter-badger,项目名称:WealthEconomy,代码行数:10,代码来源:UsersController.cs


示例18: GetAllPet

        public IList<Pet> GetAllPet(User user)
        {
            using (var session = NHibernateHelper.OpenSession())
            {

                var pets = session.CreateQuery("from Pet where user_id = :id")
                    .SetParameter("id", user.Id).List<Pet>();
                return pets;

            }
        }
开发者ID:kkc47,项目名称:PetFeedService,代码行数:11,代码来源:PetService.cs


示例19: PostUser

        public IHttpActionResult PostUser(User user)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            _userRepo.Post(user);

            return CreatedAtRoute("DefaultApi", new { id = user.Id }, user);
        }
开发者ID:ryanmcintire,项目名称:SimpleContactAPI,代码行数:11,代码来源:UsersController.cs


示例20: Post

        // POST: odata/User
        public async Task<IHttpActionResult> Post(User user)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Users.Add(user);
            await db.SaveChangesAsync();

            return Created(user);
        }
开发者ID:jcvaldes,项目名称:MyRoomV7,代码行数:13,代码来源:UserController.cs



注:本文中的System.Web.Http.User类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Http.ValuesController类代码示例发布时间:2022-05-26
下一篇:
C# Http.HttpServer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap