Exemplo n.º 1
0
        public IActionResult Upsert(ServiceVM serviceVM)
        {
            if (ModelState.IsValid)
            {
                var    files        = HttpContext.Request.Form.Files;
                string webHostRoot  = _hostEnvironment.WebRootPath;
                var    uploadFolder = Path.Combine(webHostRoot, @"images\services");

                if (serviceVM.Service.Id == 0)
                {
                    // New Service

                    var fileName = Guid.NewGuid().ToString() + "_" + files[0].FileName;
                    using (var fileStream = new FileStream(Path.Combine(uploadFolder, fileName), FileMode.Create))
                    {
                        files[0].CopyTo(fileStream);
                    }

                    serviceVM.Service.ImageUrl = @"\images\services\" + fileName;
                    _unitOfWork.ServiceRepository.Add(serviceVM.Service);
                }
                else
                {
                    // Update Service
                    var objFromDB = _unitOfWork.ServiceRepository.Get(serviceVM.Service.Id);

                    if (files.Count > 0)
                    {
                        //remove old file
                        var imagePath = Path.Combine(webHostRoot, objFromDB.ImageUrl.TrimStart('\\'));
                        if (System.IO.File.Exists(imagePath))
                        {
                            System.IO.File.Delete(imagePath);
                        }

                        //upload new file
                        var fileName = Guid.NewGuid().ToString() + "_" + files[0].FileName;
                        using (var fileStream = new FileStream(Path.Combine(uploadFolder, fileName), FileMode.Create))
                        {
                            files[0].CopyTo(fileStream);
                        }

                        serviceVM.Service.ImageUrl = @"\images\services\" + fileName;
                    }
                    else
                    {
                        serviceVM.Service.ImageUrl = objFromDB.ImageUrl;
                    }

                    _unitOfWork.ServiceRepository.Update(serviceVM.Service);
                }

                _unitOfWork.Save();

                return(RedirectToAction(nameof(Index)));
            }
            serviceVM.CategoryList  = _unitOfWork.CategoryRepository.GetCategoryForDropDown();
            serviceVM.FrequencyList = _unitOfWork.FrequencyRepository.GetFrequencyForDropDown();
            return(View(serviceVM));
        }
Exemplo n.º 2
0
 public IActionResult UpSert(int id)
 {
     try
     {
         ServiceVM service = new ServiceVM();
         if (id != 0)
         {
             service.Service    = _unitOfWork.Service.Get(id);
             service.Categorys  = _unitOfWork.Category.GetCategoryListForDropDown();
             service.Frequencys = _unitOfWork.Frequency.GetFrequencyListForDropDown();
             return(View(service));
         }
         else
         {
             service.Service    = new Service();
             service.Categorys  = _unitOfWork.Category.GetCategoryListForDropDown();
             service.Frequencys = _unitOfWork.Frequency.GetFrequencyListForDropDown();
             return(View(service));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public async Task <IActionResult> Post([FromBody] ServiceVM serviceVM)
        {
            if (serviceVM.EmployeeId == null || serviceVM.serviceIds.Count == 0)
            {
                ModelState.AddModelError("", "Не указаны данные");
                return(BadRequest(ModelState));
            }

            try
            {
                ServiceDTO serviceDTO = new ServiceDTO()
                {
                    EmployeeId = serviceVM.EmployeeId,
                    serviceIds = serviceVM.serviceIds
                };
                await _cartService.AddHotelAsync(serviceDTO);

                return(Ok(serviceVM));
            }
            catch (BusinessLogicException ex)
            {
                BadRequest(ex.Message);
            }

            return(BadRequest("Error"));
        }
Exemplo n.º 4
0
        public IActionResult Edit(ServiceVM serviceVM)
        {
            var    DBService   = db.Service.AsNoTracking().FirstOrDefault(c => c.ServiceId == serviceVM.service.ServiceId);
            var    files       = HttpContext.Request.Form.Files;
            string webRootPath = webHostEnvironment.WebRootPath;

            if (files.Count > 0)
            {
                string upload    = webRootPath + Startup.ImagePath;
                string fileName  = Guid.NewGuid().ToString();
                string extension = Path.GetExtension(files[0].FileName);
                //remove the old image
                if (DBService.Receipt != null)
                {
                    var oldFile = Path.Combine(upload, DBService.Receipt);
                    if (System.IO.File.Exists(oldFile))
                    {
                        System.IO.File.Delete(oldFile);
                    }
                }
                //add new
                using (var fileStream = new FileStream(Path.Combine(upload, fileName + extension), FileMode.Create)) {
                    files[0].CopyTo(fileStream);
                }
                serviceVM.service.Receipt = fileName + extension;
            }
            else
            {
                serviceVM.service.Receipt = DBService.Receipt;
            }
            db.Service.Update(serviceVM.service);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(Guid id, ServiceVM vm)
        {
            if (ModelState.IsValid)
            {
                var getOperation = await _bo.ReadAsync(id);

                if (!getOperation.Success)
                {
                    return(OperationErrorBackToIndex(getOperation.Exception));
                }

                if (getOperation.Result == null)
                {
                    return(RecordNotFound());
                }

                var result = getOperation.Result;

                if (!vm.CompareToModel(result))
                {
                    result = vm.ToService(result);

                    var updateOperation = await _bo.UpdateAsync(result);

                    if (!updateOperation.Success)
                    {
                        TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception);
                        return(View(vm));
                    }

                    return(OperationSuccess("The record was successfully updated."));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 6
0
        public IActionResult AddService(int?id)
        {
            var bill = _context.Bill
                       .FirstOrDefault(m => m.Bill_ID == id);

            var service = _context.Service_Detail.Where(p => p.Bill_ID == id)
                          .Join(_context.Service,
                                sd => sd.Service_ID,
                                s => s.Service_ID,
                                (sd, s) => new
            {
                Service = s
            }).ToList();

            var servicelist = new List <ServiceVM>();

            foreach (var item in service)
            {
                var ser_qty  = _context.Service_Detail.Where(p => p.Bill_ID == id && p.Service_ID == item.Service.Service_ID).FirstOrDefault();
                var ser_item = new ServiceVM
                {
                    Service          = item.Service,
                    Service_Quantity = ser_qty.Service_Quantity,
                };
                servicelist.Add(ser_item);
            }
            BillVM billVM = new BillVM
            {
                Bill       = bill,
                ServiceVMs = servicelist,
            };

            return(View());
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }

            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }

            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = ServiceVM.Parse(getOperation.Result);

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Edit", Controller = "Services", Icon = "fa-edit", Text = "Edit"
            });

            ViewData["Title"]       = "Edit service";
            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
Exemplo n.º 8
0
        public ActionResult ServiceReservation(int id)
        {
            #region Cart list

            HttpCookie    cookieCart = Request.Cookies["Cart"];
            List <string> CartList   = new List <string>();
            if (cookieCart != null)
            {
                CartList = cookieCart.Value.Split(',').ToList();
                CartList.RemoveAt(CartList.Count - 1);

                ViewBag.CartList      = CartList;
                ViewBag.CartListCount = CartList.Count;
            }
            else
            {
                ViewBag.CartListCount = 0;
            }

            List <Product> products = new List <Product>();

            foreach (var item in CartList)
            {
                foreach (var prd in db.Products.Include("ProductImages").Include("Admin").Include("ProductToCategory").Include("ProductToCategory.ProductCategory").ToList())
                {
                    if (Convert.ToInt32(item.Split('-')[0]) == prd.Id)
                    {
                        prd.Count = Convert.ToDecimal(item.Split('-')[1]);
                        products.Add(prd);
                    }
                }
            }
            ViewBag.Products = products;
            #endregion
            ViewBag.ServicePage = true;
            ViewBag.Blogs       = db.Blog.Where(c => c.isActive).OrderByDescending(c => c.PostDate).Take(3).ToList();
            ViewBag.Address     = db.Layout.FirstOrDefault().Address;
            ViewBag.Phone       = db.Layout.FirstOrDefault().Phone;
            ViewBag.Email       = db.Layout.FirstOrDefault().Email;
            ViewBag.FooterLogo  = db.Layout.FirstOrDefault().LogoFooter;
            ViewBag.HeaderLogo  = db.Layout.FirstOrDefault().Logo;
            ServiceVM v = new ServiceVM();

            v.Service  = db.Service.Include("ServiceToInfo").Include("ServiceToInfo.ServiceInfo").Include("ServiceBenefits").Where(c => c.isActive).FirstOrDefault(c => c.Id == id);
            v.Services = db.Service.Include("ServiceToInfo").Include("ServiceToInfo.ServiceInfo").Include("ServiceBenefits").Where(c => c.isActive).ToList();

            if (Session["VCS-" + id] == null)
            {
                Session["VCS-" + id] = true;


                v.Service.ViewCount = v.Service.ViewCount + 1;

                db.Entry(v.Service).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            return(View(v));
        }
Exemplo n.º 9
0
        public bool MergeService(ServiceVM serviceVM)
        {
            var service = Map <ServiceVM, Service>(serviceVM);
            var result  = _services.Merge(service);

            serviceVM.Id = service.Id;
            return(result);
        }
Exemplo n.º 10
0
        public IActionResult Upsert(ServiceVM serviceVM)
        {
            if (ModelState.IsValid)
            {
                // New Service
                string webRootPath = _hostEnvironment.WebRootPath;
                var    files       = HttpContext.Request.Form.Files;
                if (serviceVM.Service.Id == 0)
                {
                    string fileName  = Guid.NewGuid().ToString();
                    var    uploads   = Path.Combine(webRootPath, @"images\services");
                    var    extension = Path.GetExtension(files[0].FileName);

                    using (var fileStreams = new FileStream(Path.Combine(uploads, fileName + extension), FileMode.Create))
                    {
                        files[0].CopyTo(fileStreams);
                    }
                    serviceVM.Service.ImageUrl = @"\images\services\" + fileName + extension;

                    _unitOfWork.Service.Add(serviceVM.Service);
                }
                else
                {
                    // Edit Service
                    var serviceFromDB = _unitOfWork.Service.Get(serviceVM.Service.Id);
                    if (files.Count > 0)
                    {
                        string fileName      = Guid.NewGuid().ToString();
                        var    uploads       = Path.Combine(webRootPath, @"images\services");
                        var    extension_new = Path.GetExtension(files[0].FileName);

                        var imagePath = Path.Combine(webRootPath, serviceFromDB.ImageUrl.TrimStart('\\'));
                        if (System.IO.File.Exists(imagePath))
                        {
                            System.IO.File.Delete(imagePath);
                        }
                        using (var fileStreams = new FileStream(Path.Combine(uploads, fileName + extension_new), FileMode.Create))
                        {
                            files[0].CopyTo(fileStreams);
                        }
                        serviceVM.Service.ImageUrl = @"\images\services\" + fileName + extension_new;
                    }
                    else
                    {
                        serviceVM.Service.ImageUrl = serviceFromDB.ImageUrl;
                    }
                    _unitOfWork.Service.Update(serviceVM.Service);
                }
                _unitOfWork.Save();
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                serviceVM.CategoryList  = _unitOfWork.Category.GetCategoryListForDropdown();
                serviceVM.FrequencyList = _unitOfWork.Frequency.GetFrequencyListForDropDown();
                return(View(serviceVM));
            }
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }

            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }

            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getServiceOperation = await _serviceBO.ReadAsync(getOperation.Result.ServiceId);

            if (!getServiceOperation.Success)
            {
                return(OperationErrorBackToIndex(getServiceOperation.Exception));
            }

            if (getServiceOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getClientOperation = await _clientBO.ReadAsync(getOperation.Result.ClientId);

            if (!getClientOperation.Success)
            {
                return(OperationErrorBackToIndex(getClientOperation.Exception));
            }

            if (getClientOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = JobVM.Parse(getOperation.Result);

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Details", Controller = "Jobs", Icon = "fa-info-circle", Text = "Details"
            });

            ViewData["Title"]       = "Job details";
            ViewData["BreadCrumbs"] = crumbs;
            ViewData["Service"]     = ServiceVM.Parse(getServiceOperation.Result);
            ViewData["Client"]      = ClientVM.Parse(getClientOperation.Result);
            return(View(vm));
        }
Exemplo n.º 12
0
        public IActionResult Services()
        {
            ServiceVM serviceVM = new ServiceVM
            {
                Services          = _work.Services.GetAll(),
                ServiceCategories = _work.ServiceCategories.GetAll()
            };

            return(View(serviceVM));
        }
Exemplo n.º 13
0
        public IActionResult Create()
        {
            ServiceVM = new ServiceVM()
            {
                Service         = new Service(),
                CategoryList    = _unitOfWork.Category.GetCategoryListForDropDown(),
                SubCategoryList = _unitOfWork.SubCategory.GetSubCategoryListForDropDown()
            };

            return(View(ServiceVM));
        }
Exemplo n.º 14
0
        public IActionResult MergeService(MergeServiceVM mergeService)
        {
            var result  = true;
            var message = string.Empty;

            try
            {
                using (var scope = new TransactionScope(TransactionScopeOption.Suppress))
                {
                    var service = new ServiceVM
                    {
                        Id          = mergeService.Id.GetValueOrDefault(),
                        Description = mergeService.Description,
                        ServiceName = mergeService.ServiceName,
                        TypeId      = mergeService.TypeId
                    };

                    result = UnitOfWork.Services.MergeService(service);

                    if (result && mergeService.Images != null)
                    {
                        foreach (var image in mergeService.Images)
                        {
                            if (image.Updated.GetValueOrDefault() && !string.IsNullOrWhiteSpace(image.Image))
                            {
                                var imageVM = new ServiceImageVM
                                {
                                    Id        = image.Id.GetValueOrDefault(),
                                    Image     = image.Image,
                                    ServiceId = service.Id
                                };
                                result = UnitOfWork.Services.MergeServiceImage(imageVM);
                                if (!result)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    if (result)
                    {
                        scope.Complete();
                    }
                }
            }
            catch (System.Exception ex)
            {
                result  = false;
                message = ex.ToString();
            }

            return(Json(new { result, message }));
        }
Exemplo n.º 15
0
        public IActionResult Index()
        {
            ServiceVM serviceVM = new ServiceVM
            {
                Services       = _db.Services.Where(s => s.IsDeleted == false).ToList(),
                ServiceDetails = _db.ServiceDetails.Where(sd => sd.IsDeleted == false).ToList(),
                Populars       = _db.Populars.Where(p => p.IsDeleted == false).ToList(),
                PopularDetails = _db.PopularDetails.Where(pd => pd.IsDeleted == false).ToList()
            };

            return(View(serviceVM));
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            message = "";

            // These must be initialized before the UI loads
            CharacteristicVM.Initialize(GlobalSettings.SelectedCharacteristic);
            ServiceVM.Initialize(GlobalSettings.SelectedCharacteristic.ServiceM);
            DeviceVM.Initialize(GlobalSettings.SelectedCharacteristic.ServiceM.DeviceM);

            // Read the characteristic value on a separate thread
            Utilities.RunFuncAsTask(GlobalSettings.SelectedCharacteristic.ReadValueAsync);
        }
Exemplo n.º 17
0
        public IActionResult Services()
        {
            ServiceVM serviceVM = new ServiceVM
            {
                Services          = _work.Services.GetAll(),
                ServiceCategories = _work.ServiceCategories.GetAll(),
                Client            = _work.Client.GetAll(),
                blogs             = _work.Blogs.GetAll(),
            };

            return(View(serviceVM));
        }
Exemplo n.º 18
0
        private async Task <List <ServiceVM> > GetServiceViewModels(List <Guid> ids)
        {
            var filterOperation = await _serviceBO.FilterAsync(x => ids.Contains(x.Id));

            var serviceList = new List <ServiceVM>();

            foreach (var item in filterOperation.Result)
            {
                serviceList.Add(ServiceVM.Parse(item));
            }

            return(serviceList);
        }
Exemplo n.º 19
0
        public IActionResult Create()
        {
            ServiceVM serviceVM = new ServiceVM()
            {
                service           = new Service(),
                vehicleSelectList = db.Vehicle.Where(c => c.UserId == userManager.GetUserId(HttpContext.User)).Select(c => new SelectListItem {
                    Text  = c.Make + ' ' + c.Model + ' ' + c.Year,
                    Value = c.VehicleId.ToString()
                })
            };

            return(View(serviceVM));
        }
Exemplo n.º 20
0
        public ActionResult Index()
        {
            var       userId   = User.Identity.GetUserId();
            var       UserInfo = _unitOfWork.User.GetMyInfo(userId);
            var       Company  = _unitOfWork.Company.GetMyCompany(UserInfo.fCompanyId);
            ServiceVM Obj      = new ServiceVM
            {
                TheDecimalPointForTheLocalCurrency   = Company.TheDecimalPointForTheLocalCurrency,
                TheDecimalPointForTheForeignCurrency = Company.TheDecimalPointForTheForeignCurrency
            };

            return(View(Obj));
        }
Exemplo n.º 21
0
 public IActionResult Upsert(int?id)
 {
     ServVM = new ServiceVM()
     {
         Service       = new Service(),
         CategoryList  = _unitOfWork.Category.GetCategoryListForDropDown(),
         FrequencyList = _unitOfWork.Frequency.GetFrequencyListForDropDown()
     };
     if (id != null)
     {
         ServVM.Service = _unitOfWork.Service.Get(id.GetValueOrDefault());
     }
     return(View(ServVM));
 }
Exemplo n.º 22
0
        public IActionResult Service(ServiceVM serviceVM)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Invalid Username or Password");
                return(View(serviceVM));
            }

            ModelState.AddModelError("", "Invalid Username or Password");

            //var user = HttpContext.User;
            //var result = IdentityService.CallService();
            return(View());
        }
Exemplo n.º 23
0
        public ActionResult ServiceList(int?id, string searchTerm, int?sortBy)
        {
            sortBy = sortBy.HasValue ? sortBy : 1;
            //if (id == null)
            //    services=
            ServiceVM VM = new ServiceVM();

            VM.services   = filterService(searchTerm, id, sortBy);
            VM.categories = db.tbl_servicecategory.ToList();
            VM.sortBy     = sortBy.Value;
            VM.searchTerm = searchTerm;
            //var data = db.tbl_services.Where(x => x.ServiceCategoryId == id).ToList();
            return(View("ServiceList", VM));
        }
Exemplo n.º 24
0
        public ActionResult UpdateService(string id)
        {
            int ID = 0;

            if (!String.IsNullOrEmpty(id))
            {
                try
                {
                    ID = int.Parse(id.ToString());
                }
                catch
                {
                    ID = 0;
                }
            }

            try
            {
                if (ID != 0)
                {
                    var userId   = User.Identity.GetUserId();
                    var UserInfo = _unitOfWork.User.GetUserByID(userId);
                    var sService = _unitOfWork.Service.GetServiceByID(UserInfo.fCompanyId, ID);
                    if (UserInfo == null)
                    {
                        RedirectToAction("", "");
                    }
                    ServiceVM Obj = new ServiceVM();
                    Obj.ServiceID      = sService.ServiceID;
                    Obj.ServiceGroup   = _unitOfWork.ServiceGroup.GetAllServiceGroup(UserInfo.fCompanyId);
                    Obj.ServiceGroupID = sService.ServiceGroupID;
                    Obj.ArabicName     = sService.ArabicName;
                    Obj.EnglishName    = sService.EnglishName;
                    Obj.Note           = sService.Note;
                    Obj.CostPrice      = sService.CostPrice;
                    Obj.SalePrice      = sService.SalePrice;
                    Obj.TaxPercentage  = sService.TaxPercentage;
                    return(PartialView("UpdateService", Obj));
                }



                return(PartialView("UpdateService", new Service()));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message.ToString();
                return(View("Error"));
            }
        }
Exemplo n.º 25
0
        public JsonResult Insert_Service(ServiceVM objects)
        {
            bool result = false;

            string msg = "Failed to save record..";

            result = MasterMethods.Insert_Service(objects);

            if (result)
            {
                msg = "Successfully Added";
            }

            return(Json(new { Success = result, Message = msg }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 26
0
        public ActionResult AddNew()
        {
            var       userId   = User.Identity.GetUserId();
            var       UserInfo = _unitOfWork.User.GetMyInfo(userId);
            ServiceVM Obj      = new ServiceVM
            {
                ServiceID     = _unitOfWork.Service.GetMaxSerial(UserInfo.fCompanyId),
                ServiceGroup  = _unitOfWork.ServiceGroup.GetAllServiceGroup(UserInfo.fCompanyId),
                CostPrice     = 0.000,
                SalePrice     = 0.000,
                TaxPercentage = 0.0
            };

            return(PartialView(Obj));
        }
Exemplo n.º 27
0
        public IActionResult Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ServiceVM = new ServiceVM();

            ServiceVM.Service     = _unitOfWork.Service.Get(id.GetValueOrDefault());
            ServiceVM.Category    = _unitOfWork.Category.GetFirstOrDefault(c => c.Id == ServiceVM.Service.CategoryId);
            ServiceVM.SubCategory = _unitOfWork.SubCategory.GetFirstOrDefault(c => c.Id == ServiceVM.Service.SubCategoryId);

            return(View(ServiceVM));
        }
Exemplo n.º 28
0
        public IActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ServiceVM serviceVM = new ServiceVM()
            {
                Services      = _db.Services.Include(s => s.ServiceImages).ToList(),
                Servicee      = _db.Services.Find(id),
                ServiceImages = _db.ServiceImages.Where(s => s.ServiceId == id).Take(2).ToList()
            };

            return(View(serviceVM));
        }
Exemplo n.º 29
0
        // Set up entry into page
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Reset list choice
            if (_characteristicListBox != null)
            {
                _characteristicListBox.SelectedIndex = -1;
            }

            // These must be initialized before the UI loads
            DeviceVM.Initialize(GlobalSettings.SelectedService.DeviceM);
            ServiceVM.Initialize(GlobalSettings.SelectedService);
            Characteristics.Initialize(ServiceVM.ServiceM.CharacteristicModels);

            // Read all characteristic values
            Utilities.RunFuncAsTask(GlobalSettings.SelectedService.ReadCharacteristicsAsync);
        }
Exemplo n.º 30
0
        public async Task <IActionResult> New(ServiceVM vm)
        {
            if (ModelState.IsValid)
            {
                var model           = vm.ToService();
                var createOperation = await _bo.CreateAsync(model);

                if (!createOperation.Success)
                {
                    return(OperationErrorBackToIndex(createOperation.Exception));
                }

                return(OperationSuccess("The record was successfully created."));
            }
            return(View(vm));
        }