public IActionResult OrderTrack(long?id)
        {
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Order, EN_Permissions.Edit))
            {
                return(Redirect("/Home"));
            }

            var result = new Order();

            if (id != null)
            {
                result = _uow.OrderRepository.GetAll().Where(ent => ent.Id == id)
                         .Include(ent => ent.Customer)
                         .Include(ent => ent.ResponsibleUser)
                         .Include(ent => ent.OrderTrackAction)
                         .Include(ent => ent.OrderTracks).ThenInclude(ent => ent.OrderTrackAction)
                         .Include(ent => ent.OrderItems).ThenInclude(ent => ent.Item).ThenInclude(ent => ent.Service)
                         .Include(ent => ent.OrderService).ThenInclude(ent => ent.Service)
                         .Include(ent => ent.OrderTechAssign).ThenInclude(ent => ent.TechnicalUser)
                         .FirstOrDefault();
                if (result == null)
                {
                    return(NotFound());
                }
            }
            else
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Order, EN_Permissions.Create))
                {
                    return(Redirect("/Home"));
                }
            }
            return(View(result));
        }
        //reject order
        public IActionResult Delete(long id)
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Order, EN_Permissions.RejectOrder))
            {
                return(Redirect("/Home"));
            }

            string status       = "success";
            string errorMessage = "";

            try
            {
                var order = _uow.OrderRepository.GetById(id);
                if (order == null)// || order.OrderTrackActionId==(int)OrderActions.completed)
                {
                    status       = "error";
                    errorMessage = "Delete Error message";
                }
                else
                {
                    order.ModifiedBy         = AppSession.CurrentUser.Id;
                    order.ModificationDate   = DateTime.Now;
                    order.OrderTrackActionId = (int)EN_OrderActions.rejected;
                    _uow.OrderRepository.Update(order);
                    _uow.Save();
                }
            }
            catch (Exception ex)
            {
                status       = "error";
                errorMessage = "Delete Error message";
            }
            return(Json(new { status = status, ErrorMessage = errorMessage }));
        }
        public IActionResult OpenForm(long?id)
        {
            var entity = new Customer();

            //assign default image to customer
            entity.ImageName = AppSession.CustomerDefaultImage;
            if (id != null)
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Customer, EN_Permissions.Edit))
                {
                    return(Redirect("/Home"));
                }

                entity = _uow.CustomerRepository.GetById(id);

                if (entity == null || entity.IsDeleted)
                {
                    return(NotFound());
                }
            }
            else
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Customer, EN_Permissions.Create))
                {
                    return(Redirect("/Home"));
                }
            }

            return(View(entity));
        }
        public IActionResult OpenForm(long?id)
        {
            var entity = new Order();

            if (id != null)
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Order, EN_Permissions.Edit))
                {
                    return(Redirect("/Home"));
                }

                entity = _uow.OrderRepository.GetById(id);
                if (entity == null || entity.IsDeleted)
                {
                    return(NotFound());
                }
            }
            else
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Order, EN_Permissions.Create))
                {
                    return(Redirect("/Home"));
                }
            }
            FillFormDropdowns(entity);
            return(View(entity));
        }
Example #5
0
        public IActionResult Delete(long id)
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Groups, EN_Permissions.Delete))
            {
                return(Redirect("/Home"));
            }

            string status       = "success";
            string errorMessage = "";

            try
            {
                var dbObj = _uow.GroupsRepository.GetById(id);
                if (dbObj == null || dbObj.IsMaster)
                {
                    status       = "error";
                    errorMessage = "Delete Error Msg";
                }
                else
                {
                    dbObj.IsDeleted        = true;
                    dbObj.ModifiedBy       = AppSession.CurrentUser.Id;
                    dbObj.ModificationDate = DateTime.Now;
                    _uow.GroupsRepository.Update(dbObj);
                    _uow.Save();
                }
            }
            catch (Exception ex)
            {
                status       = "error";
                errorMessage = "Delete Error Msg";
            }
            return(Json(new { status, ErrorMessage = errorMessage }));
        }
Example #6
0
        public IActionResult OpenForm(long?id)
        {
            var entity = new Users();

            entity.Technical = new Technical();
            //assign default image to Users
            entity.ImageName = AppSession.UserDefaultImage;
            if (id != null)
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Users, EN_Permissions.Edit))
                {
                    return(Redirect("/Home"));
                }

                entity = _uow.UsersRepository.GetAll().Where(ent => ent.Id == id).Include(ent => ent.Technical).FirstOrDefault();
                if (entity == null || entity.IsDeleted)
                {
                    return(NotFound());
                }
            }
            else
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Users, EN_Permissions.Create))
                {
                    return(Redirect("/Home"));
                }
            }
            FillFormDropdowns(entity);
            return(View(entity));
        }
        public IActionResult SaveAssignResponsible(long orderId, long responsibleUserId)
        {
            string status = "success";

            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Order, EN_Permissions.Edit))
            {
                return(Redirect("/Home"));
            }

            var order    = _uow.OrderRepository.Get(ent => ent.Id == orderId);
            var supplier = _uow.UsersRepository.Get(ent => ent.Id == responsibleUserId);

            if (order == null)
            {
                status = "error";
                return(Json(new { status = status, ErrorMessage = "Order Not Found" }));
            }
            else if (supplier == null)
            {
                status = "error";
                return(Json(new { status = status, ErrorMessage = "Supplier Not Found" }));
            }
            else if (order.ResponsibleUserId != null && order.ResponsibleUserId != 0)
            {
                status = "error";
                return(Json(new { status = status, ErrorMessage = "Order Already has Responsible User !" }));
            }
            else
            {
                //update order responsible
                order.ResponsibleUserId = responsibleUserId;
                order.ModificationDate  = DateTime.Now;
                order.ModifiedBy        = AppSession.CurrentUser.Id;

                order.OrderTrackActionId = (int)EN_OrderActions.accpted_by_user;
                _uow.OrderRepository.Update(order);

                var customername = _uow.CustomerRepository.Get(ent => ent.Id == order.CustomerId).ArabicName;
                var suppliername = _uow.UsersRepository.Get(ent => ent.Id == responsibleUserId).ArabicName;

                //send notification to customer that his order accepted by technical
                Notification notification = new Notification();
                notification.Text       = "Order With Code: " + order.Code + " Accepted by supplier: " + suppliername;
                notification.ToUSer     = order.CustomerId;
                notification.URl        = "/Order/OrderTrack" + orderId;
                notification.TypeOfUser = (int)EN_TypeUser.Customer;
                _uow.NotificationRepository.Add(notification);

                ////send notification with order assigned by admin to supplier
                //Notification techNotification = new Notification();
                //techNotification.Text = "Order With Code: " + order.Code + " For Customer " + customername + " Added to you By Admin ";
                //techNotification.TypeOfUser = (int)EN_TypeUser.Technical;
                //notification.ToUSer = responsibleUserId;
                //_uow.NotificationRepository.Add(techNotification);

                _uow.Save();
                return(Json(new { status = status }));
            }
        }
Example #8
0
        public IActionResult Index()
        {
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Country, EN_Permissions.View))
            {
                return(Redirect("/Home"));
            }

            var result = _uow.CountryRepository.GetAll().OrderByDescending(ent => ent.CreationDate).ToHashSet();

            return(View(result));
        }
        public IActionResult Index()
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.CustomerReview, EN_Permissions.View))
            {
                return(Redirect("/Home"));
            }

            var result = _uow.CustomerReviewRepository.GetAll().OrderByDescending(ent => ent.Id).ToHashSet();

            return(View(result));
        }
        public IActionResult Index()
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _Security, AppSession.CurrentUser.Id, EN_Screens.Offers, EN_Permissions.View))
            {
                return(Redirect("/Home/Index"));
            }
            var result = new HashSet <Offer>();

            result = _uow.OffersRepository.GetMany(ent => !ent.IsDeleted).ToHashSet();

            return(View(result));
        }
        public IActionResult Index()
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _Security, AppSession.CurrentUser.Id, EN_Screens.Items, EN_Permissions.View))
            {
                return(Redirect("/Home/Index"));
            }

            var result = _uow.ItemsRepository.GetAll().Include(ent => ent.Service).OrderByDescending(ent => ent.CreationDate).ToHashSet();

            FillFormDropdowns(new Item());
            return(View(result));
        }
Example #12
0
        public ActionResult OpenForm(long id)
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.SystemOptions, EN_Permissions.Edit))
            {
                return(Redirect("/Home/Index"));
            }

            SystemOption entity = _uow.SystemOptionsRepository.GetById(id);

            if (entity == null || entity.IsDeleted || entity.IsHidden)
            {
                return(NotFound());
            }

            return(View(entity));
        }
Example #13
0
        public IActionResult Index()
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Users, EN_Permissions.View))
            {
                return(Redirect("/Home"));
            }

            var result = _uow.UsersRepository.GetAll();

            if (AppSession.CurrentUser.JobTitleId == (int)En_JobTitle.egent)
            {
                result = result.Where(ent => ent.CityId == AppSession.CurrentUser.CityId);
            }
            FillFormDropdowns(new Users());
            return(View(result.OrderByDescending(ent => ent.CreationDate).ToHashSet()));
        }
Example #14
0
        public ActionResult Index()
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.SystemOptions, EN_Permissions.View))
            {
                return(Redirect("/Home/Index"));
            }


            var result = new HashSet <SystemOption>();

            result = _uow.SystemOptionsRepository.GetMany(ent => ent.IsActive && !ent.IsDeleted && !ent.IsHidden).ToHashSet();

            var categories = result.Select(ent => new { id = ent.Id, text = ent.CategoryArName }).Distinct().ToHashSet();

            ViewBag.categories = new SelectList(categories, "id", "text");
            return(View(result));
        }
        public IActionResult Index()
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Order, EN_Permissions.View))
            {
                return(Redirect("/Home"));
            }
            var orders = _uow.OrderRepository.GetMany(ent => ent.OrderItems != null && ent.OrderItems.Count > 0)
                         .Include(ent => ent.Customer)
                         .Include(ent => ent.OrderTrackAction)
                         .Include(ent => ent.ResponsibleUser)
                         .Include(ent => ent.OrderItems)
                         .OrderByDescending(ent => ent.CreationDate).ToHashSet();

            FillFormDropdowns(new Order());

            return(View(orders));
        }
Example #16
0
        public IActionResult Permissions(long id)
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Groups, EN_Permissions.Edit))
            {
                return(Redirect("/Home"));
            }

            var group = new Groups();

            group = _uow.GroupsRepository.Get(ent => ent.Id == id && !ent.IsDeleted);
            if (group == null)
            {
                return(NotFound());
            }

            ViewBag.modules = _uow.ModulesRepository.GetMany(ent => ent.IsActive && !ent.IsDeleted).ToHashSet();
            return(View(group));
        }
        public IActionResult CompleteOrder(long id)
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.ServicesReport, EN_Permissions.CompleteOrder))
            {
                return(Redirect("/Home"));
            }

            string status       = "success";
            string errorMessage = "";

            try
            {
                var order = _uow.OrderRepository.GetById(id);
                if (order == null || order.OrderTrackActionId >= (int)EN_OrderActions.completed)
                {
                    status       = "error";
                    errorMessage = "Order not found";
                }
                else
                {
                    order.ModifiedBy         = AppSession.CurrentUser.Id;
                    order.ModificationDate   = DateTime.Now;
                    order.OrderTrackActionId = (int)EN_OrderActions.completed;
                    order.DeliverDate        = DateTime.Now;
                    _uow.OrderRepository.Update(order);
                    //add order track action
                    OrderTrack action = new OrderTrack();
                    action.CreatedBy          = AppSession.CurrentUser.Id;
                    action.CreationDate       = DateTime.Now;
                    action.OrderId            = order.Id;
                    action.OrderTrackActionId = (int)EN_OrderActions.completed;
                    _uow.OrderTrackRepository.Add(action);
                    _uow.Save();
                }
            }
            catch (Exception ex)
            {
                status       = "error";
                errorMessage = "Complete Order Error message";
            }
            return(Json(new { status = status, ErrorMessage = errorMessage }));
        }
        public IActionResult OpenForm(long?id)
        {
            var entity = new Offer();

            //entity.From = DateTime.Now;
            //entity.To = DateTime.Now.AddDays(1);
            entity.ImagePath = AppSession.OfferDefaultImage;
            if (id != null)
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _Security, AppSession.CurrentUser.Id, EN_Screens.Offers, EN_Permissions.Edit))
                {
                    return(Redirect("/Home/Index"));
                }

                entity = _uow.OffersRepository.GetById(id);
                if (entity == null || entity.IsDeleted)
                {
                    return(NotFound());
                }
                var offersNum = _uow.OffersRepository.GetMany(ent => ent.IsActive && !ent.IsDeleted && ent.Id == id).Count();

                ViewBag.offersNum = offersNum;
            }
            else
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _Security, AppSession.CurrentUser.Id, EN_Screens.Offers, EN_Permissions.Create))
                {
                    return(Redirect("/Home/Index"));
                }
                var offersNum = _uow.OffersRepository.GetAll().Count();

                if (offersNum >= 4)
                {
                    entity.IsActive = false;
                }
                ViewBag.offersNum = offersNum;
            }
            FillFormDropdowns(entity);
            return(View(entity));
        }
        public IActionResult Delete(long id)
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _Security, AppSession.CurrentUser.Id, EN_Screens.Offers, EN_Permissions.Delete))
            {
                return(Redirect("/Home/Index"));
            }
            string status       = "success";
            string errorMessage = "";

            try
            {
                var dbObj    = _uow.OffersRepository.GetById(id);
                var invoices = 1;
                //invoices = _uow.InvoicesRepository.GetMany(ent => ent.IsActive && !ent.IsDeleted).Count();
                if (dbObj == null)
                {
                    status       = "error";
                    errorMessage = "Delete Error Msg";
                }
                else if (invoices > 0)
                {
                    status       = "error";
                    errorMessage = "This Offer is related to invoices";
                }
                else
                {
                    dbObj.IsDeleted        = true;
                    dbObj.ModifiedBy       = AppSession.CurrentUser.Id;
                    dbObj.ModificationDate = DateTime.Now;
                    _uow.OffersRepository.Update(dbObj);
                    _uow.Save();
                }
            }
            catch (Exception)
            {
                status       = "error";
                errorMessage = "Delete Error Msg";
            }
            return(Json(new { status, errorMessage }));
        }
Example #20
0
        public IActionResult Orders(long id)
        {
            //var json = new OrderController(_uow, _security).UserOrders(UserId);
            //Check User Permission For this Page
            ViewBag.UserId = id;
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Order, EN_Permissions.View))
            {
                return(Redirect("/Home"));
            }

            var orders = _uow.OrderRepository.GetAll().Include(ent => ent.Customer)
                         .Include(ent => ent.OrderTrackAction)
                         .Include(ent => ent.ResponsibleUser)
                                                                                                       //.Include(ent => ent.OrderTrack)
                                                                                                       //orders which user responsible for
                                                                                                       //orders which has last user assignment with wait state to the current user
                         .Where(ent => (ent.ResponsibleUserId != null && ent.ResponsibleUserId == id)) // || (ent.OrderTrackActionId == (int)OrderActions.ordered))
                         .ToHashSet();

            return(View(orders));
        }
Example #21
0
        public IActionResult Index()
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.TechnicalsReport, EN_Permissions.View))
            {
                return(Redirect("/Home"));
            }

            var Technicals = _uow.TechnicalsRepository.GetAll();

            if (AppSession.CurrentUser.JobTitleId == (int)En_JobTitle.egent)
            {
                Technicals = Technicals.Include(ent => ent.User)
                             .Where(ent => ent.User.CityId == AppSession.CurrentUser.CityId);
            }

            Technicals = Technicals.Include(ent => ent.User).ThenInclude(ent => ent.Orders).ThenInclude(ent => ent.OrderService)
                         .Include(ent => ent.Service);
            FillFormDropdowns(new Users());
            return(View(Technicals.ToHashSet()));
        }
Example #22
0
        public IActionResult Delete(long id)
        {
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Country, EN_Permissions.Delete))
            {
                return(Redirect("/Home"));
            }

            string status       = "success";
            string errorMessage = "";

            try
            {
                var dbObj = _uow.CountryRepository.GetById(id);
                if (dbObj == null)
                {
                    status       = "error";
                    errorMessage = "Delete Error message";
                }
                else
                {
                    _uow.ExecuteSqlCommand("UPDATE district " +
                                           "SET IsDeleted = 1 ,ModifiedBy = " + AppSession.CurrentUser.Id + " ,ModificationDate = '" + DateTime.Now + "' " +
                                           "From district inner join City on City.Id = district.CityId Where (district.IsDeleted = 0 ) AND (City.CountryId =" + id.ToString() + ")");
                    _uow.ExecuteSqlCommand("UPDATE City " +
                                           "SET IsDeleted = 1 ,ModifiedBy = " + AppSession.CurrentUser.Id + " ,ModificationDate = '" + DateTime.Now + "' " +
                                           "Where (IsDeleted = 0 ) AND (CountryId =" + id.ToString() + ")");
                    dbObj.IsDeleted        = true;
                    dbObj.ModifiedBy       = AppSession.CurrentUser.Id;
                    dbObj.ModificationDate = DateTime.Now;
                    _uow.CountryRepository.Update(dbObj);
                    _uow.Save();
                }
            }
            catch (Exception ex)
            {
                status       = "error";
                errorMessage = "Delete Error message";
            }
            return(Json(new { status = status, ErrorMessage = errorMessage }));
        }
Example #23
0
        public IActionResult OpenForm(long?id)
        {
            var entity = new Country();

            if (id != null)
            {
                //Check User Permission For this Page
                if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.Country, EN_Permissions.Edit))
                {
                    return(Redirect("/Country/Index"));
                }

                entity = _uow.CountryRepository.GetById(id);
                if (entity == null || entity.IsDeleted)
                {
                    return(NotFound());
                }
            }


            return(View(entity));
        }
        public IActionResult AssignResponsible(long?id)
        {
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.ServicesReport, EN_Permissions.Edit))
            {
                return(Redirect("/Home"));
            }

            var result = _uow.OrderRepository.Get(ent => ent.Id == id);

            if (id == null || result == null)
            {
                return(NotFound());
            }

            var AssignResponsibleList = _uow.UsersRepository.GetMany(ent => ent.IsActive && !ent.IsDeleted && ent.JobTitleId == (int)En_JobTitle.Supplier)
                                        .Select(ent => new SelectListItem {
                Value = ent.Id.ToString(), Text = ent.ArabicName
            })
                                        .ToHashSet();

            ViewBag.AssignResponsibleList = new SelectList(AssignResponsibleList, "Value", "Text");
            return(View(result));
        }
        public IActionResult Index()
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.ServicesReport, EN_Permissions.View))
            {
                return(Redirect("/Home"));
            }

            var orders = _uow.OrderRepository.GetMany(ent => ent.OrderService != null)
                         .Include(ent => ent.Customer)
                         .Include(ent => ent.OrderTrackAction)
                         .Include(ent => ent.ResponsibleUser)
                         .Include(ent => ent.OrderService).ThenInclude(ent => ent.Service)
                         .ToHashSet();

            if (AppSession.CurrentUser != null && AppSession.CurrentUser.JobTitleId == (long)En_JobTitle.egent)
            {
                orders = orders.Where(ent => ent.Customer != null && ent.Customer.CityId == AppSession.CurrentUser.CityId).ToHashSet();
            }
            FillFormDropdowns(new Order());

            return(View(orders));
        }
        public IActionResult Delete(long id)
        {
            //Check User Permission For this Page
            if (!UserAccountMannager.HasPermission(_uow, _security, AppSession.CurrentUser.Id, EN_Screens.CustomerReview, EN_Permissions.Delete))
            {
                return(Redirect("/Home"));
            }

            string status       = "success";
            string errorMessage = "";

            try
            {
                _uow.ExecuteSqlCommand("Delete From CustomerReview Where id='" + id + "'");

                _uow.Save();
            }
            catch (Exception ex)
            {
                status       = "error";
                errorMessage = "Delete Error message";
            }
            return(Json(new { status, ErrorMessage = errorMessage }));
        }