예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            string resultTrans = "success";

            try
            {
                var prescriptionList = medicineRepository.GetPrescriptionByMedicineId(id);
                if (prescriptionList.Count() == 0)
                {
                    var      objSession = Session["user"] as MyClinic.Infrastructure.SessUser;
                    Medicine medicine   = medicineRepository.GetMedicineById(id);

                    var newMedicine = ObjectCopier.Copy <Medicine>(medicine);
                    newMedicine.Status = 0;

                    medicineRepository.UpdateFieldChangedOnly(medicine, newMedicine);
                    /*For Add New Record to LogTable*/
                    logTran.UserId      = objSession.UserId;
                    logTran.ProcessType = "Delect medicine";
                    logTran.Description = "Delect medicine Name: " + medicine.Name;
                    logTran.LogDate     = DateTime.Now;
                    logRepository.Add(logTran);
                }
                else
                {
                    resultTrans = "failure";
                    return(Json(new { result = resultTrans, proccessType = "Delete", Id = id, strName = Translator.ThisMedicine, strUsed = Translator.MsgPrescription }));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
            return(Json(new { result = resultTrans, proccessType = "Delete", Id = id }));
        }