Пример #1
0
        public async Task <ActionResult <JsonR> > changeStatus(long ReceptionId, int IdWaiting)//,string comment="")
        {
            string   today = MYHelper.PersianDate(MYHelper.GetDate());
            DateTime from  = MYHelper.DiffDate(today, true).AddDays(-7);
            DateTime to    = MYHelper.DiffDate(today, false);
            JsonR    result;
            var      lst   = repository.GetAll().Result;
            tblVisit model = lst.FirstOrDefault(c => c.IdReception == ReceptionId && c.VisitDate >= from && c.VisitDate <= to);

            if (model == null)
            {
                result = new JsonR {
                    Title = "error", Message = "ویزیت به تاریخ امروز وجود ندارد"
                };
                return(result);
            }
            model.IdWaiting = IdWaiting;
            ContextDb db = new ContextDb();

            db.tblReceptions.Find(ReceptionId).IdWaiting = IdWaiting;

            //if (!string.IsNullOrEmpty(comment))
            //    model.Comment = comment;
            db.SaveChanges();
            result = new JsonR {
                Title = "success", Message = "عملیات با موفقیت انجام شد"
            };
            return(result);
        }
        public async Task <ActionResult <bool> > Post(tblReception model)
        {
            try
            {
                ContextDb db = new ContextDb();
                model.Id = 0;
                tbl_patient patient = model.tbl_patient;

                if (patient.Id <= 0)
                {
                    string dossier = string.Empty;
                    if (db.tbl_patient.Count() > 0)
                    {
                        dossier = (Convert.ToInt64(db.tbl_patient.Max(c => c.DossierNumberPermanent)) + 1).ToString().PadLeft(6, '0');
                    }

                    else
                    {
                        dossier = "000001";
                    }
                    patient.DossierNumberPermanent = dossier;
                    db.tbl_patient.Add(patient);
                }
                else
                {
                    db.Entry(patient).State = EntityState.Modified;
                }
                db.SaveChanges();
                model.IdPatient      = patient.Id;
                model.tbl_patient    = null;
                model.IdWaiting      = 4;
                model.RegDate        = MYHelper.GetDate();
                model.IdGeneralGroup = 1;
                var service = db.tbl_Service.Find(model.IdService);
                model.tblVisits.ToList().ForEach(c =>
                {
                    c.Id          = 0;
                    c.IdWaiting   = 4;
                    c.DateRequest = MYHelper.GetDate();
                    c.IdReception = model.Id;
                    c.VisitDate   = MYHelper.GetDate(c.FarsiDate);
                    c.Count       = 1;
                    c.Percents    = 100;
                    c.FreePrices  = service.FreePrices;
                    c.Tariff      = service.FreePrices;
                });

                await repository.Add(model);

                return(true);
            }
            catch (Exception err)
            {
                return(false);
            }
        }
Пример #3
0
        public async Task <ActionResult <bool> > Post(tblVisit model)
        {
            try
            {
                model.VisitDate = MYHelper.GetDate(model.FarsiDate);
                await repository.Add(model);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #4
0
        public async Task <ActionResult <bool> > Put(long id, tblVisit model)
        {
            if (id != model.Id)
            {
                return(BadRequest());
            }

            try
            {
                model.VisitDate = MYHelper.GetDate(model.FarsiDate);
                await repository.Update(model);

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }
        }