Esempio n. 1
0
        public JsonResult SaveVisit([FromBody] DeliveryItemVisitMobile model)
        {
            model.LawUnitId = GetLawUnitId();
            if (model.CourtId <= 0)
            {
                model.CourtId = GetCourtId();
            }
            var result = deliveryItemService.DeliveryItemSaveOperMobile(model);

            return(Json(result));
        }
Esempio n. 2
0
        public bool CheckMobileFile(DeliveryMobileFile mobileFile, bool saveNotFound)
        {
            var    stream  = new MemoryStream(mobileFile.Content);
            string content = "";

            using (StreamReader sr = new StreamReader(stream))
                content = sr.ReadToEnd();
            List <DeliveryItemVisitMobile> visits;

            try
            {
                var dateTimeConverter = new IsoDateTimeConverter()
                {
                    DateTimeFormat = FormattingConstant.NormalDateFormat
                };
                visits = JsonConvert.DeserializeObject <List <DeliveryItemVisitMobile> >("[" + content + "]", dateTimeConverter);
            }
            catch (Exception ex)
            {
                mobileFile.IsChecked    = true;
                mobileFile.ErrorMessage = ex.Message;
                repo.Update(mobileFile);
                repo.SaveChanges();
                return(true);
            }
            string error = "";

            foreach (var visit in visits)
            {
                string visitID = "delivery_itemId = " + visit.DeliveryItemId + " and delivery_uuid = " + visit.DeliveryUUID;
                if (visit.UserId == "TEST" || visit.UserId == "DELETE")
                {
                    continue;
                }
                var saved = repo.AllReadonly <DeliveryItemVisitMobile>()
                            .Where(x => x.DeliveryItemId == visit.DeliveryItemId &&
                                   x.DeliveryUUID == visit.DeliveryUUID)
                            .FirstOrDefault();
                if (saved == null)
                {
                    if (saveNotFound)
                    {
                        bool isOK = deliveryItemService.DeliveryItemSaveOperMobile(visit);
                        if (!isOK)
                        {
                            error += visitID + " не е записан правилно" + Environment.NewLine;
                        }
                    }
                    else
                    {
                        error += visitID + " не е намерен" + Environment.NewLine;
                    }
                }
                else
                {
                    if (!saved.IsOK)
                    {
                        error += visitID + " не е записан правилно" + Environment.NewLine;
                    }
                }
            }
            mobileFile.IsChecked    = true;
            mobileFile.ErrorMessage = error;
            repo.Update(mobileFile);
            repo.SaveChanges();
            return(true);
        }