Пример #1
0
        public ActionResult UpdateUserMaintenance(string key, string values)
        {
            //Get Data and Merge
            UserMaintenanceViewModel UserUpdate = new UserMaintenanceViewModel();

            //this.SecurityService.GetUserMaintenance(new UserCriteria() { UserID = key}).FirstOrDefault().ToModel();
            JsonConvert.PopulateObject(values, UserUpdate);
            ValidateModel(UserUpdate);
            if (!TryValidateModel(UserUpdate))                           // Validating the updated item
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserUpdate.Password    = CommonUtils.Encrypt(UserUpdate.Password);
            UserUpdate.UpdatedBy   = UserDetail.UserID;
            UserUpdate.UpdatedDate = CurrentDateTime;
            this.SecurityService.UpdateUser(UserUpdate.ToEntity(), UserUpdate.CompanyCodeList, UserUpdate.PlantCodeList);

            return(new HttpStatusCodeResult(HttpStatusCode.Created));
        }
Пример #2
0
        public ActionResult InsertUserMaintenance(string values)
        {
            UserMaintenanceViewModel userInsert = new UserMaintenanceViewModel();

            JsonConvert.PopulateObject(values, userInsert);

            //check duplicate
            //UserMaintenanceViewModel userDup = this.SecurityService.GetUserMaintenance(new UserCriteria() { UserID = userInsert.UserID }).FirstOrDefault().ToModel();
            //if (userDup != null)
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "User ID is Duplicate");
            userInsert.Password    = CommonUtils.Encrypt(userInsert.Password);
            userInsert.CreatedBy   = userInsert.UpdatedBy = UserDetail.UserID;
            userInsert.CreatedDate = userInsert.UpdatedDate = CurrentDateTime;
            ValidateModel(userInsert);
            if (!TryValidateModel(userInsert))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            this.SecurityService.InsertUser(userInsert.ToEntity(), userInsert.CompanyCodeList, userInsert.PlantCodeList);
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }