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));
        }
        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));
        }
Exemple #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));
        }
        public ActionResult GetUserPointDetails(int UserId)
        {
            object result = "";

            try
            {
                var    peymentReuest       = new B_UserPayment().GetPayment(UserId);
                var    peymentRequestItems = new B_ServicesRequestItems().GetItem(UserId, E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER);
                var    res = new List <DetaildPointModel>();
                double pointPay = 0, pointRecive = 0;
                var    payStatus = new B_PublicCategory().GetPublicCategory(E_PublicCategory.PUBLIC_CATEGORY_PARENT.PAYMENT_STATUS);
                var    payType   = new B_PublicCategory().GetPublicCategory(E_PublicCategory.PUBLIC_CATEGORY_PARENT.PAYMENT_TYPE);

                foreach (var li in peymentReuest)
                {
                    res.Add(new DetaildPointModel
                    {
                        Title    = payType.Where(c => c.Id == (int)li.Type).FirstOrDefault().Title,
                        Date     = li.CreateDate.ConvertToPesianDateName(true),
                        Time     = li.CreateDate.Hour + ":" + li.CreateDate.Minute + ":" + li.CreateDate.Second,
                        Score    = (li.Point * -1).ToString(),
                        Status   = payStatus.Where(c => c.Id == (int)li.Status).FirstOrDefault().Title,
                        RealDate = li.CreateDate
                    });
                    if (li.Status != E_PublicCategory.PAYMENT_STATUS.FAILED)
                    {
                        pointPay += li.Point * -1;
                    }
                }

                foreach (var li in peymentRequestItems)
                {
                    res.Add(new DetaildPointModel
                    {
                        Title    = li.Title,
                        Date     = li.CreateDate.ConvertToPesianDateName(true),
                        Time     = li.CreateDate.Hour + ":" + li.CreateDate.Minute + ":" + li.CreateDate.Second,
                        Score    = ((li.Value.HasValue ? li.Value.Value : 0) * li.ScorePerUnit).ToString(),
                        Status   = "ثبت شده",
                        RealDate = li.CreateDate
                    });
                    pointRecive += (li.Value.HasValue ? li.Value.Value : 0) * li.ScorePerUnit;
                }

                var user = new B_Users().GetUsers(UserId);
                result = new
                {
                    PointSummery = new { PointPay = pointPay, PointRecive = pointRecive, PointTotal = pointRecive + pointPay },
                    PointDetails = res.OrderByDescending(c => c.RealDate).ToList(),
                    User         = new { Name = user.FirstName + " " + user.LastName, RegisterDate = user.RegisterDate.ConvertToPesianDateName(true), Tell = user.MobileNumber }
                };
            }
            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));
        }