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 Delete(int Id)
        {
            object result = "";

            try
            {
                B_ServicesCategories bServicesCategories = new B_ServicesCategories();
                var oldServicesCategories = bServicesCategories.GetServicesCategories(Id);
                bServicesCategories.Delete(Id);
                try
                {
                    System.IO.File.Delete(Server.MapPath("~/Images/Categories/xxxhdpi") + "/" + oldServicesCategories.ImageName);
                    System.IO.File.Delete(Server.MapPath("~/Images/Categories/xxhdpi") + "/" + oldServicesCategories.ImageName);
                    System.IO.File.Delete(Server.MapPath("~/Images/Categories/xhdpi") + "/" + oldServicesCategories.ImageName);
                    System.IO.File.Delete(Server.MapPath("~/Images/Categories/hdpi") + "/" + oldServicesCategories.ImageName);
                    System.IO.File.Delete(Server.MapPath("~/Images/Categories/mdpi") + "/" + oldServicesCategories.ImageName);
                }
                catch { }
                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));
        }
Example #4
0
        public ActionResult StationMode()
        {
            ViewBag.Date = getDate();
            B_ServicesCategories bCat = new B_ServicesCategories();
            var categories            = bCat.GetServicesCategories(true);

            ViewBag.ElecScore     = categories.Where(x => x.Id == 2).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.MetalScore    = categories.Where(x => x.Id == 3).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.NonMetalScore = categories.Where(x => x.Id == 8).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.RandomScore   = categories.Where(x => x.Id == 9).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.UserId        = CurrentUser.Id;
            return(View());
        }
        public ActionResult RequestDetails(int Id)
        {
            B_ServicesCategories bCat = new B_ServicesCategories();
            var categories            = bCat.GetServicesCategories(true);

            ViewBag.ElecScore     = categories.Where(x => x.Id == 2).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.MetalScore    = categories.Where(x => x.Id == 3).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.NonMetalScore = categories.Where(x => x.Id == 8).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.RandomScore   = categories.Where(x => x.Id == 9).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.Request       = new B_ServicesRequests().GetFullServicesRequests(Id);
            ViewBag.RequestItems  = new B_ServicesRequestItems().GetItems(Id);
            return(View());
        }
        public ActionResult Modify(int Id)
        {
            ViewBag.Route = new List <MFRoute>
            {
                new MFRoute {
                    ActionName = "Index", ControllerName = "Categories", Title = "لیست دسته بندی ها", Priority = 1
                }
            };
            var bServicesCategories = new B_ServicesCategories();
            var servicesCategories  = bServicesCategories.GetServicesCategories(Id);

            if (servicesCategories == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(servicesCategories));
        }
Example #7
0
 public IHttpActionResult GetCategory(int?Id)
 {
     try
     {
         List <object> obj        = new List <object>();
         var           categories = new B_ServicesCategories().GetServicesCategories(Id.HasValue ? Id.Value : 0, true);
         if (categories != null && categories.Count > 0)
         {
             foreach (var li in categories)
             {
                 obj.Add(new {
                     CreateDate   = li.CreateDate,
                     DeactiveDate = li.DeactiveDate,
                     Description  = li.Description,
                     HaveNew      = li.HaveNew,
                     Id           = li.Id,
                     ImageUrl     = GetImageAddress(li.ImageName, new E_FTPRoutes(BaseUrl).CATEGORIES),
                     IsActive     = li.IsActive,
                     Lineages     = li.Lineages,
                     ParentId     = li.ParentId,
                     Route        = li.Route,
                     ScorePerUnit = li.ScorePerUnit,
                     Title        = li.Title,
                     Unit         = li.Unit,
                     CategoryId   = li.Id
                 });
             }
         }
         return(Json(PrepareSuccessResult(obj)));
     }
     catch (Exception ex)
     {
         M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
         if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
         {
             exx.LogType = E_LogType.SYSTEM_ERROR;
         }
         L_Log.SubmitLog(exx);
         if (ex.Source != E_LogType.SYSTEM_ERROR.ToString())
         {
             return(Json(PrepareFaildResult("خطایی در سرور وجود دارد", (int)E_ErrorCodes.SERVER_ERROR + S_Seprators.ErrorFieldNameSeprator.ToString() + "")));
         }
         return(Json(PrepareFaildResult(exx.LogMessage, ex.HelpLink)));
     }
 }
        public ActionResult GetCategory(int ParentId)
        {
            object result = "";

            try
            {
                result = new B_ServicesCategories().GetServicesCategories(ParentId, false);
            }
            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));
        }
Example #9
0
        public ActionResult RideMode()
        {
            //var Cars = new B_Location().GetDriversLocation();
            var markers = "";

            //foreach (var li in booth)
            //{
            //    markers += (markers == "" ? "" : ",") + "{ 'StationId' : '" + li.Id + "' , 'popupContent': '" + getMapPupWindow(li) + "', 'center': { 'lat': " + li.Lat + " ,'lng': " + li.Lng + " }, 'iconOpts': { 'iconUrl': '/Areas/User/Images/CapLogo.png', 'iconSize': [30, 30] } }";
            //}
            //ViewBag.Stations = markers;
            ViewBag.Date = getDate();
            B_ServicesCategories bCat = new B_ServicesCategories();
            var categories            = bCat.GetServicesCategories(true);

            ViewBag.ElecScore     = categories.Where(x => x.Id == 2).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.MetalScore    = categories.Where(x => x.Id == 3).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.NonMetalScore = categories.Where(x => x.Id == 8).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.RandomScore   = categories.Where(x => x.Id == 9).Select(x => x.ScorePerUnit).FirstOrDefault();
            ViewBag.UserId        = CurrentUser.Id;
            ViewBag.Addresses     = new B_Addresses().GetAddresses(CurrentUser.Id, true);
            return(View());
        }
        public ActionResult Add(M_ServicesCategories ServicesCategories)
        {
            object result = "";

            try
            {
                var bServicesCategories = new B_ServicesCategories();
                bServicesCategories.Add(ServicesCategories);
                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 Modify(M_ServicesCategories ServicesCategories)
        {
            object result = "";

            try
            {
                B_ServicesCategories bServicesCategories = new B_ServicesCategories();
                var oldServicesCategories = bServicesCategories.GetServicesCategories(ServicesCategories.Id);
                bServicesCategories.Edit(ServicesCategories);
                if (oldServicesCategories.ImageName.ToLower() != "default.png" && oldServicesCategories.ImageName.ToLower() != ServicesCategories.ImageName)
                {
                    try
                    {
                        System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Images/Categories/xxxhdpi") + "/" + oldServicesCategories.ImageName);
                        System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Images/Categories/xxhdpi") + "/" + oldServicesCategories.ImageName);
                        System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Images/Categories/xhdpi") + "/" + oldServicesCategories.ImageName);
                        System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Images/Categories/hdpi") + "/" + oldServicesCategories.ImageName);
                        System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Images/Categories/mdpi") + "/" + oldServicesCategories.ImageName);
                    }
                    catch { }
                }
                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));
        }
Example #12
0
 public IHttpActionResult GetAllCategories()
 {
     try
     {
         B_ServicesCategories bCategory = new B_ServicesCategories();
         var category = B_PublicFunctions.GenericMaper <M_ServicesCategories, V_ServicesCategories>(bCategory.GetServicesCategories(false));
         category = prepareCategoryViewModel(0, category);
         return(Json(PrepareSuccessResult(category)));
     }
     catch (Exception ex)
     {
         M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
         if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
         {
             exx.LogType = E_LogType.SYSTEM_ERROR;
         }
         L_Log.SubmitLog(exx);
         if (ex.Source != E_LogType.SYSTEM_ERROR.ToString())
         {
             return(Json(PrepareFaildResult("خطایی در سرور وجود دارد", (int)E_ErrorCodes.SERVER_ERROR + S_Seprators.ErrorFieldNameSeprator.ToString() + "")));
         }
         return(Json(PrepareFaildResult(exx.LogMessage, ex.HelpLink)));
     }
 }
Example #13
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 Index()
        {
            var bCategory = new B_ServicesCategories();

            return(View(bCategory.GetServicesCategories(false)));
        }