Beispiel #1
0
        public async Task <IActionResult> UpdatePatient(Patient patient)
        {
            /*if (id != patient.HCN)
             * {
             *  return BadRequest();
             * }*/

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PatientExists(patient.HCN))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(View("Index"));
        }
Beispiel #2
0
        public async Task <IActionResult> PutAppointment(string id, Appointment appointment)
        {
            if (id != appointment.AppointmentID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #3
0
        public async Task <IActionResult> PutEmployee(int id, Employee employee)
        {
            if (id != employee.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IActionResult> PutBilling(int id, Billing billing)
        {
            if (id != billing.BillingID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #5
0
        //[HttpPost]
        public JsonResult UpdateData(Medium model)
        {
            string retn = String.Empty;

            using (EMSContext db = new EMSContext())
            {
                try
                {
                    if (model != null && model.Id > 0)
                    {
                        var exist = db.Mediums.Where(e => e.Id == model.Id).SingleOrDefault();
                        if (exist != null)
                        {
                            var duplicate = db.Mediums.Where(e => e.Id != model.Id && e.MediumName == model.MediumName && e.InstId == InstId).SingleOrDefault();
                            if (duplicate == null)
                            {
                                exist.Id         = model.Id;
                                exist.InstId     = InstId;
                                exist.MediumName = model.MediumName;
                                exist.ModifyId   = CurrentUserId;
                                exist.ModifyTime = DateTime.Now;
                                db.Mediums.Attach(exist);
                                db.Entry(exist).State = EntityState.Modified;
                                db.SaveChanges();
                                //if (selectedShifts != null)
                                //{
                                //    db.ShiftsMediums.RemoveRange(db.ShiftsMediums.Where(c => c.MediumId == model.Id));
                                //    foreach (string shiftId in selectedShifts)
                                //    {
                                //        var shiftMedium = new ShiftMedium();
                                //        shiftMedium.MediumId = model.Id;
                                //        shiftMedium.ShiftId = Convert.ToInt32(shiftId);
                                //        db.ShiftsMediums.Add(shiftMedium);
                                //    }
                                //    db.SaveChanges();
                                //}
                                retn = "Success.";
                            }
                            else
                            {
                                retn = "This Name Already Exist.";
                            }
                        }
                        else
                        {
                            retn = "Medium ID is not found.";
                        }
                    }
                }
                catch
                {
                    retn = "Failed";
                }
            }

            return(Json(retn, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Test test)
 {
     if (ModelState.IsValid)
     {
         db.Entry(test).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(test));
 }
Beispiel #7
0
 public ActionResult Edit([Bind(Include = "Id,Name,CountryId")] State state)
 {
     if (ModelState.IsValid)
     {
         db.Entry(state).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CountryId = new SelectList(db.Countries, "Id", "Name", state.CountryId);
     return(View(state));
 }
Beispiel #8
0
        //[HttpPost]
        public JsonResult UpdateData(Institute model)
        {
            string retn = String.Empty;

            using (EMSContext db = new EMSContext())
            {
                try
                {
                    if (model != null && model.Id > 0)
                    {
                        var exist = db.Institutes.Where(e => e.Id == model.Id).SingleOrDefault();
                        if (exist != null)
                        {
                            var duplicate = db.Institutes.Where(e => e.Id != model.Id && e.ShortName == model.ShortName).FirstOrDefault();
                            if (duplicate == null)
                            {
                                exist.Id         = model.Id;
                                exist.Name       = model.Name;
                                exist.ShortName  = model.ShortName;
                                exist.Address    = model.Address;
                                exist.Email      = model.Email;
                                exist.Phone      = model.Phone;
                                exist.Mobile     = model.Mobile;
                                exist.Contact    = model.Contact;
                                exist.IsActive   = model.IsActive;
                                exist.JoinDate   = model.JoinDate;
                                exist.ExpireDate = model.ExpireDate;
                                exist.ModifyId   = CommonFunction.CurrentUserId();
                                exist.ModifyTime = DateTime.Now;
                                db.Institutes.Attach(exist);
                                db.Entry(exist).State = EntityState.Modified;
                                db.SaveChanges();
                                retn = "Success.";
                            }
                            else
                            {
                                retn = "This Short Name Already Exist.";
                            }
                        }
                        else
                        {
                            retn = "Institute Id is not found.";
                        }
                    }
                }
                catch
                {
                    retn = "Failed";
                }
            }

            return(Json(retn, JsonRequestBehavior.AllowGet));
        }
 public Boolean UpdateEmployee(Emp emp)
 {
     try
     {
         _context.Entry(emp).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #10
0
 public bool UpdateEmployee(Employee employee)
 {
     try
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         //logger
         return(false);
     }
 }
Beispiel #11
0
        public JsonResult UpdateData(Shift model)
        {
            //var CurrentUserInstituteId = CommonFunction.CurrentUserInstituteId();
            string retn = String.Empty;

            using (EMSContext db = new EMSContext())
            {
                try
                {
                    if (model != null && model.Id > 0)
                    {
                        var exist = db.Shifts.Where(e => e.Id == model.Id).SingleOrDefault();
                        if (exist != null)
                        {
                            var duplicate = db.Shifts.Where(e => e.Id != model.Id && e.ShiftName == model.ShiftName && e.MediumId == model.MediumId && e.InstId == InstId).SingleOrDefault();
                            if (duplicate == null)
                            {
                                exist.Id         = model.Id;
                                exist.InstId     = InstId;
                                exist.MediumId   = model.MediumId;
                                exist.ShiftName  = model.ShiftName;
                                exist.ModifyId   = CurrentUserId;
                                exist.ModifyTime = DateTime.Now;
                                db.Shifts.Attach(exist);
                                db.Entry(exist).State = EntityState.Modified;
                                db.SaveChanges();
                                retn = "Success.";
                            }
                            else
                            {
                                retn = "This Name Already Exist.";
                            }
                        }
                        else
                        {
                            retn = "Shift ID is not found.";
                        }
                    }
                }
                catch
                {
                    retn = "Failed";
                }
            }

            return(Json(retn, JsonRequestBehavior.AllowGet));
        }
Beispiel #12
0
        public JsonResult UpdateData(Class model)
        {
            string retn = String.Empty;

            using (EMSContext db = new EMSContext())
            {
                try
                {
                    if (model != null && model.Id > 0)
                    {
                        var exist = db.Classes.Where(e => e.Id == model.Id).SingleOrDefault();
                        if (exist != null)
                        {
                            var duplicate = db.Classes.Where(e => e.Id != model.Id && e.Name == model.Name && e.FormatId == model.FormatId).SingleOrDefault();
                            if (duplicate == null)
                            {
                                exist.Id         = model.Id;
                                exist.Name       = model.Name;
                                exist.FormatId   = model.FormatId;
                                exist.ModifyId   = CurrentUserId;
                                exist.ModifyTime = DateTime.Now;
                                db.Classes.Attach(exist);
                                db.Entry(exist).State = EntityState.Modified;
                                db.SaveChanges();
                                retn = "Success.";
                            }
                            else
                            {
                                retn = "This Name Already Exist.";
                            }
                        }
                        else
                        {
                            retn = "Class ID is not found.";
                        }
                    }
                }
                catch
                {
                    retn = "Failed";
                }
            }

            return(Json(retn, JsonRequestBehavior.AllowGet));
        }
Beispiel #13
0
        //[HttpPost]
        public JsonResult UpdateData(Employee employee)
        {
            string retn = String.Empty;

            using (EMSContext db = new EMSContext())
            {
                try
                {
                    if (employee != null && employee.ID > 0)
                    {
                        var CurrentEmployee = db.Employees.Where(e => e.ID == employee.ID).SingleOrDefault();
                        if (CurrentEmployee != null)
                        {
                            var UpdateEmployee = db.Employees.Where(e => e.ID != employee.ID && e.Name == employee.Name).SingleOrDefault();
                            if (UpdateEmployee == null)
                            {
                                CurrentEmployee.ID      = employee.ID;
                                CurrentEmployee.Name    = employee.Name;
                                CurrentEmployee.Address = employee.Address;
                                db.Employees.Attach(CurrentEmployee);
                                db.Entry(CurrentEmployee).State = EntityState.Modified;
                                db.SaveChanges();
                                retn = "Success.";
                            }
                            else
                            {
                                retn = "This Name Already Exist.";
                            }
                        }
                        else
                        {
                            retn = "Employee ID is not found.";
                        }
                    }
                }
                catch
                {
                    retn = "Failed";
                }
            }

            return(Json(retn, JsonRequestBehavior.AllowGet));
        }
Beispiel #14
0
        public IActionResult Regjistro(Employee employee)
        {
            try
            {
                logger.LogDebug("Regjistro()");
                if (ModelState.IsValid)
                {
                    employee.Status = true;

                    context.Entry(employee).Property("CreatedBy").IsModified   = false;
                    context.Entry(employee).Property("DateCreated").IsModified = false;

                    context.Employee.Add(employee);
                    context.SaveChanges();
                    logger.LogDebug("New Employee was created by " + User.Identity.Name);
                    TempData["registered"] = true;

                    context.Logs.Add(new Logs {
                        mesazhi   = $"Employee {employee.FirstName} {employee.LastName} was added with id: {employee.Id}",
                        createdBy = User.FindFirst(ClaimTypes.NameIdentifier).Value,
                        createdAt = DateTime.Now
                    });
                    context.SaveChanges();

                    return(RedirectToAction("Allemployees"));
                }
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception e)
            {
                LogException(e);

                logger.LogError("Error creating new Employee", e);
                return(RedirectToAction("Error", "Home"));
            }
        }