public ActionResult Modify(M_ServicesRequests ServicesRequests, List <M_ServicesRequestItems> RequestList)
        {
            object result = "";

            try
            {
                var request = new B_ServicesRequests().GetServicesRequests(ServicesRequests.Id);
                if (request != null)
                {
                    request.Address            = ServicesRequests.Address;
                    request.Description        = ServicesRequests.Description;
                    request.ImmediatelyRequest = ServicesRequests.ImmediatelyRequest;
                    request.PlaqueNumber       = ServicesRequests.PlaqueNumber;
                    request.UnitNumber         = ServicesRequests.UnitNumber;
                    request.UpdateDate         = DateTime.Now;
                    new B_ServicesRequests().Edit(request, false);
                }
                var bItems   = new B_ServicesRequestItems();
                var oldItems = bItems.GetItems(ServicesRequests.Id, E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER);
                foreach (var li in oldItems)
                {
                    bItems.Delete(li.Id);
                }
                foreach (var li in RequestList)
                {
                    if (!li.CategoryId.HasValue)
                    {
                        throw F_ExeptionFactory.MakeExeption("مقادیر دسته بندی های انتخاب شده صحیح نیست لطفا مراتب را سریعتر به تیم فنی پروژه گزارش دهید", Enums.Loging.E_LogType.SYSTEM_ERROR);
                    }
                    var category = new B_ServicesCategories().GetServicesCategories(li.CategoryId.Value);
                    li.CategoryId         = category.Id;
                    li.CreateDate         = category.CreateDate;
                    li.ImageName          = category.ImageName;
                    li.IsFailed           = false;
                    li.RequestId          = ServicesRequests.Id;
                    li.ScorePerUnit       = category.ScorePerUnit;
                    li.ScorePerUnitDriver = category.ScorePerUnitDriver;
                    li.Title    = category.Title;
                    li.Unit     = category.Unit;
                    li.UserId   = request.UserId;
                    li.UserType = E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER;
                    li.Id       = 0;
                    bItems.Add(li);
                }

                result = "Success";
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Exemplo n.º 2
0
        public ActionResult EditRequest(int RequestId, List <M_ServicesRequestItems> RequestItems)
        {
            object result = "";

            try
            {
                var bItem    = new B_ServicesRequestItems();
                var oldItems = bItem.GetItems(RequestId, E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER);
                var userId   = new B_ServicesRequests().GetServicesRequests(RequestId).UserId;
                foreach (var li in oldItems)
                {
                    bItem.Delete(li.Id);
                }
                if (RequestItems != null && RequestItems.Count > 0)
                {
                    foreach (var li in RequestItems)
                    {
                        if (li.Value != 0)
                        {
                            var category = new B_ServicesCategories().GetServicesCategories(li.Id);
                            if (category != null)
                            {
                                bItem.Add(new M_ServicesRequestItems
                                {
                                    CreateDate   = DateTime.Now,
                                    RequestId    = RequestId,
                                    UserType     = E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER,
                                    Value        = li.Value,
                                    ImageName    = category.ImageName,
                                    ScorePerUnit = category.ScorePerUnit,
                                    Title        = category.Title,
                                    Unit         = category.Unit,
                                    IsFailed     = false,
                                    UserId       = userId,
                                    CategoryId   = category.Id
                                });
                            }
                        }
                    }
                }
                result = true;
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_BOOTH_RIDER_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
Exemplo n.º 3
0
        public ActionResult AddRequestCar(RequestModelAddRequest Data)
        {
            object result = "";

            try
            {
                if (!isValidUserForInsertRequest("CAR"))
                {
                    throw F_ExeptionFactory.MakeExeption("کاربر گرامی تا اتمام درخواست قبلی،امکان ثبت درخواست جدید میسر نمیباشد",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (string.IsNullOrEmpty(Data.Address))
                {
                    throw F_ExeptionFactory.MakeExeption("آدرس وارد شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (Data.DayId == 0)
                {
                    throw F_ExeptionFactory.MakeExeption("روز انتخاب شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (Data.TimeId == 0)
                {
                    throw F_ExeptionFactory.MakeExeption("ساعت انتخاب شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                //if (string.IsNullOrEmpty(Data.Description))
                //    throw F_ExeptionFactory.MakeExeption("توضیحات وارد شده صحیح نیست",
                //        ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                if (Data.UnitNumber == 0)
                {
                    throw F_ExeptionFactory.MakeExeption("شماره واحد وارد شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (Data.PlaqueNumber == 0)
                {
                    throw F_ExeptionFactory.MakeExeption("شماره پلاک وارد شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                bool rqItems = true;
                if (Data.RequestItems.Count > 0)
                {
                    foreach (var li in Data.RequestItems)
                    {
                        if (li.Value > 0)
                        {
                            rqItems = false;
                        }
                    }
                }
                if (rqItems)
                {
                    throw F_ExeptionFactory.MakeExeption("پسماندهای خود را به دسته بندی اضافه کنید",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                var bServicesRequests = new B_ServicesRequests();
                var request           = new M_ServicesRequests
                {
                    Address                 = Data.Address,
                    Description             = Data.Description,
                    GeographicalCoordinates = Data.Lat + "," + Data.Lng,
                    PlaqueNumber            = Data.PlaqueNumber.ToString(),
                    Pouriya_DateId          = 0,
                    Pouriya_TimeId          = 0,
                    Pouriya_Type            = "CAR",
                    Status     = E_PublicCategory.REQUEST_STATUS.NEW_REQUEST,
                    UnitNumber = Data.UnitNumber.ToString(),
                    UserId     = CurrentUser.Id,
                    PersonelId = null,
                    CreateDate = DateTime.Now,
                };
                request = bServicesRequests.Add(request);
                var bItem = new B_ServicesRequestItems();
                if (Data.RequestItems != null && Data.RequestItems.Count > 0)
                {
                    foreach (var li in Data.RequestItems)
                    {
                        if (li.Value != 0)
                        {
                            var category = new B_ServicesCategories().GetServicesCategories(li.Id);
                            if (category != null)
                            {
                                bItem.Add(new M_ServicesRequestItems
                                {
                                    CreateDate   = DateTime.Now,
                                    RequestId    = request.Id,
                                    UserType     = E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER,
                                    Value        = li.Value,
                                    ImageName    = category.ImageName,
                                    ScorePerUnit = category.ScorePerUnit,
                                    Title        = category.Title,
                                    Unit         = category.Unit,
                                    IsFailed     = false,
                                    UserId       = CurrentUser.Id,
                                    CategoryId   = category.Id
                                });
                            }
                        }
                    }
                }

                try
                {
                    var hubConnection = new HubConnection(url: SignalRUrl);
                    var chat          = hubConnection.CreateHubProxy(hubName: "Reqeust");

                    hubConnection.Start().Wait();

                    chat.Invoke <bool>("NewRequestDriver", request);
                }
                catch { }
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_USER_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }