Пример #1
0
        public async Task <IActionResult> PutClientUserByEmail([FromRoute] string email, [FromBody] EditUserViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dbUser = _context.Client.AsNoTracking().SingleOrDefault(x => x.Email == email);

            ClientUser user = new ClientUser
            {
                Email             = dbUser.Email,
                StreetName        = vm.StreetName,
                HouseNumber       = vm.HouseNumber,
                Province          = vm.Province,
                District          = vm.District,
                PasswordHash      = dbUser.PasswordHash,
                AccessFailedCount = dbUser.AccessFailedCount,
                BirthDay          = dbUser.BirthDay,
                ConcurrencyStamp  = dbUser.ConcurrencyStamp,
                EmailConfirmed    = dbUser.EmailConfirmed,
                FirstName         = dbUser.FirstName,
                Gender            = dbUser.Gender,
                HealthWorker_Id   = dbUser.HealthWorker_Id,
                Id                   = dbUser.Id,
                LastName             = dbUser.LastName,
                LockoutEnabled       = dbUser.LockoutEnabled,
                LockoutEnd           = dbUser.LockoutEnd,
                NormalizedEmail      = dbUser.NormalizedEmail,
                NormalizedUserName   = dbUser.NormalizedUserName,
                PhoneNumber          = dbUser.PhoneNumber,
                PhoneNumberConfirmed = dbUser.PhoneNumberConfirmed,
                SecurityStamp        = dbUser.SecurityStamp,
                TwoFactorEnabled     = dbUser.TwoFactorEnabled,
                UserName             = dbUser.UserName,
            };

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientUserExists(email))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public ActionResult AcceptBooking(int?id)
        {
            Booking booking = db.Bookings.Find(id);

            booking.Status = "confirmed";

            updateSchedule(booking.Schedule.ScheduleId, booking.Item.Weight);

            db.Entry(booking).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> PutAppointmentDetail(int id, AppointmentDetail appointmentDetail)
        {
            if (id != appointmentDetail.AppointmentId)
            {
                return(BadRequest());
            }

            _context.Entry(appointmentDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppointmentDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutPaymentDetails(int id, PaymentDetails paymentDetails)
        {
            if (id != paymentDetails.pmId)
            {
                return(BadRequest());
            }

            _context.Entry(paymentDetails).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PaymentDetailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public bool SaveUser(User user)
        {
            bool status = true;

            try
            {
                UserDBContext userDBContext = new UserDBContext();
                if (user.Id > 0)
                {
                    if (userDBContext.Users.Where(obj => obj.Id == user.Id).Any())
                    {
                        userDBContext.Entry(user).State = EntityState.Modified;
                        userDBContext.SaveChanges();
                    }
                    else
                    {
                        status = false;
                    }
                }
                else
                {
                    userDBContext.Users.Add(user);
                    userDBContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                status = false;
            }

            return(status);
        }
Пример #6
0
        public async Task <IActionResult> PutClientUser([FromRoute] string id, [FromBody] ClientUser clientUser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != clientUser.Id)
            {
                return(BadRequest());
            }

            _context.Entry(clientUser).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #7
0
        public async Task <IActionResult> PutUserRole(int id, UserRole userRole)
        {
            if (id != userRole.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(userRole).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserRoleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #8
0
        //DELETE api/v1/users?name=
        public async Task <IHttpActionResult> Delete(string name)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            var updateResult = await Task <bool> .Factory.StartNew(() =>
            {
                bool result = false;
                using (var context = new UserDBContext())
                {
                    var existingUser = context.Users.Where(s => s.UserName == name).FirstOrDefault();
                    if (existingUser != null)
                    {
                        context.Entry(existingUser).State = System.Data.Entity.EntityState.Deleted;
                        context.SaveChanges();
                        result = true;
                    }
                }

                return(result);
            });

            if (updateResult == false)
            {
                return(NotFound());
            }

            return(Ok());
        }
Пример #9
0
        public async Task <IActionResult> PutUserTb([FromRoute] int id, [FromBody] UserTb userTb)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != userTb.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(userTb).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserTbExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #10
0
        public async Task <IActionResult> PutCandidat(int id, Candidat candidat)
        {
            if (id != candidat.IdCandidat)
            {
                return(BadRequest());
            }

            _context.Entry(candidat).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CandidatExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #11
0
        public ActionResult upgrade(string UserId, string UserClass)
        {
            try
            {
                if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Admin))
                {
                    return(RedirectToAction("PermitionEr", "Error"));
                }

                var result = from a in db.Users.ToList()
                             where a.UserId == UserId
                             select a;
                foreach (var item in result)
                {
                    item.UserClass       = UserClass;
                    db.Entry(item).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(Redirect("/home/"));
            }
            catch
            {
                return(RedirectToAction("LoginEr", "Error"));
            }
        }
Пример #12
0
 public ActionResult Edit([Bind(Include = "Id,NickName,Email,Phone,Name")] UserAccount userAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userAccount));
 }
Пример #13
0
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,Country,City,Address,Email,Birthdate,Mobilephone,isAdmin")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Пример #14
0
 public ActionResult Edit([Bind(Include = "ItemId,ItemName,Customer,Weight,Source,Destination")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
 public ActionResult Edit([Bind(Include = "id,roleName")] Role role)
 {
     if (ModelState.IsValid)
     {
         db.Entry(role).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(role));
 }
Пример #16
0
 //[Authorize(Roles = "Administrator")]
 public ActionResult Edit([Bind(Include = "PaymentModeId,PaymentMode")] PaymentModeMaster paymentModeMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(paymentModeMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(paymentModeMaster));
 }
Пример #17
0
 //[Authorize(Roles = "Administrator")]
 public ActionResult Edit([Bind(Include = "InstallmentId,Installment")] InstallmentMaster installmentMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(installmentMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(installmentMaster));
 }
Пример #18
0
 //[Authorize(Roles = "Administrator")]
 public ActionResult Edit([Bind(Include = "ProgrammeId,ProgrammeName,ModuleId")] ProgrammeMaster programmeMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(programmeMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(programmeMaster));
 }
Пример #19
0
 public ActionResult Edit([Bind(Include = "ID,Title,Publisher,Price,Isbn")] Library library)
 {
     if (ModelState.IsValid)
     {
         db.Entry(library).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(library));
 }
Пример #20
0
 public ActionResult Edit([Bind(Include = "BookingId,Status")] Booking booking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(booking));
 }
Пример #21
0
 public ActionResult Edit([Bind(Include = "username,firstname,lastname,email,password")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Пример #22
0
        public ResponseService UpdateUser(int id, User user)
        {
            ResponseService     response  = new ResponseService();
            GeneradorRespuestas generador = new GeneradorRespuestas();

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

            if (!UserExists(id))
            {
                response = generador.GetIncorrectResponse(404, "El usuario no existe");
            }
            else
            {
                _context.SaveChanges();
                response = generador.GetCorrectResponse(null, "El usuario fue actualizado correctamente");
            }

            return(response);
        }
Пример #23
0
 public ActionResult Edit([Bind(Include = "ShipId,ShipName,IMO")] Ship ship)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ship).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ship));
 }
 //[Authorize(Roles = "Administrator")]
 public ActionResult Edit([Bind(Include = "ModuleId,Module")] ModuleMaster moduleMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(moduleMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(moduleMaster));
 }
Пример #25
0
 public ActionResult Edit([Bind(Include = "UserId,UserNo,UserName,UserClass,UserPassword")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Пример #26
0
 public ActionResult Edit([Bind(Include = "ID,Username,Userpassword,ReleaseDate,UserFlg")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Пример #27
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Пример #28
0
 public ActionResult Edit([Bind(Include = "ID,name,lastname,birthdate,identityNo,gender")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
 public ActionResult Edit([Bind(Include = "id,userName,firstName,lastName,password,emailID,DateofJoin,managerID")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Пример #30
0
 public ActionResult Edit([Bind(Include = "ID,OpenID,NickName,IsValid")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }