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));
        }