コード例 #1
0
        public async Task <int> Update(ServiceViewModel model)
        {
            var sv = await db.Services.AsNoTracking().FirstOrDefaultAsync(x => x.Id == model.Id);

            sv.ServiceName     = model.ServiceName;
            sv.Description     = model.Description;
            model.ModifiedDate = DateTime.Now;
            model.ModifiedBy   = model.CreatedBy;
            sv.Money           = model.Money;
            db.Services.Update(sv);
            var rs = await db.SaveChangesAsync();

            return(rs); // 1 thanh cong, 0 that bai
        }
コード例 #2
0
        public ActionResult Edit(ServiceViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Service service = db.Services.SingleOrDefault(x => x.Id == vm.Id);

                service.Name = vm.Name;

                db.Services.AddOrUpdate(service);
                db.SaveChanges();
                return(RedirectToAction("Details", "Machines", new { id = vm.MachineId, customerId = vm.CustomerId }));
            }
            return(View(vm));
        }
コード例 #3
0
 public DashboardController(ILogger <DashboardController> logger, IUserProfileService userProfileService,
                            IProjectService projectService, IEducationsService educationService, IUserServicesService userServices)
 {
     _logger             = logger;
     _profile            = new AllUserProfileViewModel();
     _singleUser         = new UserProfileViewModel();
     _userProfileService = userProfileService;
     _projectService     = projectService;
     _educationService   = educationService;
     _userService        = userServices;
     _serviceViewModel   = new ServiceViewModel();
     _projectViewModel   = new EditProjectViewModel();
     _educationViewModel = new EducationViewModel();
 }
コード例 #4
0
        public ActionResult Create(ServiceViewModel serviceViewModel)
        {
            if (ModelState.IsValid)
            {
                var service = new Service()
                {
                    Title = serviceViewModel.Title
                };
                _repository.Create(service);
                return(RedirectToAction("Index"));
            }

            return(View(serviceViewModel));
        }
コード例 #5
0
        public ViewResult EditService(long serviceId)
        {
            var context = _serviceProvider.GetRequiredService <AppointmentJournalContext>();

            var service = context.Services.Include(x => x.Category).SingleOrDefault(s => s.Id == serviceId);

            var serviceViewModel = new ServiceViewModel()
            {
                Service  = service,
                Category = service.Category
            };

            return(View(serviceViewModel));
        }
コード例 #6
0
        public ActionResult Update(int id)
        {
            var entity             = JsonConvert.DeserializeObject <ServiceViewModel>(HttpService.Get("service", "Get", id).ToString());
            ServiceViewModel model = new ServiceViewModel();

            model.Title        = entity.Title;
            model.Description  = entity.Description.Replace("<img src=\"../../", "<img src=\"../../../");
            model.CategoryId   = entity.CategoryId;
            model.Id           = entity.Id;
            model.Period       = entity.Period;
            model.Price        = entity.Price;
            model.CategoryList = JsonConvert.DeserializeObject <List <Category> >(HttpService.Get("category", "GetAll?DataType=" + (short)DataType.Service).ToString());
            return(View(model));
        }
コード例 #7
0
        private void btnVerify_Click(object sender, EventArgs e)
        {
            TerminalService  ts      = new TerminalService();
            ServiceViewModel service = ts.getService(txtServiceCode.Text);

            if (service == null || String.IsNullOrWhiteSpace(service.Name))
            {
                this.enableVerifyLabels(null);
            }
            else
            {
                this.enableVerifyLabels(service);
            }
        }
コード例 #8
0
        public ActionResult Edit(ServiceViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }
            var service = _dbContext.Services.Single(s => s.Id == viewModel.Id);

            service.Name        = viewModel.Name;
            service.Price       = decimal.Parse(viewModel.Price);
            service.Description = viewModel.Description;
            _dbContext.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public async Task <IActionResult> EditService(ServiceViewModel model)
        {
            if (ModelState.IsValid)
            {
                var service = await _converterHelper.ToServiceAsync(model, false);

                _dataContext.Services.Update(service);
                await _dataContext.SaveChangesAsync();

                return(RedirectToAction($"{nameof(DetailsActivity)}/{model.ActivityId}"));
            }

            return(View(model));
        }
コード例 #10
0
        public void SaveCommandCannotExecuteWhenPriceIsNotValid()
        {
            var viewModel = new ServiceViewModel()
            {
                ServiceRecord = new Service
                {
                    Name    = "Boqdisvane",
                    Measure = "m2",
                    Price   = Convert.ToDecimal(null)
                }
            };

            Assert.Throws <NullReferenceException>(() => viewModel.SaveServiceCommand.CanExecute(null));
        }
コード例 #11
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServiceViewModel service = _serviceManager.GetService(id);

            if (service == null)
            {
                return(HttpNotFound());
            }
            return(View(service));
        }
コード例 #12
0
        public override void Execute(object parameter)
        {
            var serviceViewModel = new ServiceViewModel();

            serviceViewModel.ServiceModels = _serviceManager.GetModels();

            var userControl = new ServicesUserControl();

            userControl.DataContext = serviceViewModel;

            _mainViewModel.Grid.Children.Clear();

            _mainViewModel.Grid.Children.Add(userControl);
        }
コード例 #13
0
        public IActionResult AddService()
        {
            var myService = _userService.CreateProject("", "");
            var service   = new ServiceViewModel
            {
                ServiceDescription = myService.ServiceDescription,
                ServiceId          = myService.ServiceId,

                ServiceName = myService.ServiceName,
                UserI       = myService.UserId
            };

            return(View(service));
        }
コード例 #14
0
        public void SaveCommandCannotExecuteWhenNameIsNotValid()
        {
            var viewModel = new ServiceViewModel()
            {
                ServiceRecord = new Service
                {
                    Name    = null,
                    Measure = "m2",
                    Price   = 2.0m
                }
            };

            Assert.Throws <NullReferenceException>(() => viewModel.SaveServiceCommand.CanExecute(null));
        }
コード例 #15
0
        public ActionResult Create()
        {
            ViewBag.Title  = "Yeni Alan Ekle";
            ViewBag.Action = ActionType.Save;

            var images = _unitOfWork.Image.GetImages();

            var viewModel = new ServiceViewModel()
            {
                AllImages = images
            };

            return(View(viewModel));
        }
コード例 #16
0
        public IActionResult CreateServiceNotes(ServiceViewModel obj)
        {
            //var ServiceCust = new ServiceCustomer();
            //ServiceCust = _db.ServiceCustomers.Find(obj.Note.CustomerId);


            obj.Note.Category = "Contract Notes";
            _db.Notes.Add(obj.Note);
            _db.SaveChanges();
            var ServiceCust = new ServiceCustomer();

            ServiceCust = _db.ServiceCustomers.FirstOrDefault(c => c.CustomerId == obj.Note.CustomerId);
            return(RedirectToAction("UpdateServiceContract", new { ServiceCust.Id }));
        }
コード例 #17
0
 public void getParams(Controllers.ServiceController bookController, ServiceViewModel model)
 {
     clientIp        = (bookController.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? bookController.Request.ServerVariables["REMOTE_ADDR"]).Split(',')[0].Trim();
     username        = (string)(bookController.Session["User"] ?? "Anonymous");
     actionName      = bookController.ControllerContext.RouteData.Values["action"].ToString();
     controllerName  = bookController.ControllerContext.RouteData.Values["controller"].ToString();
     httpRequestType = bookController.ControllerContext.HttpContext.Request.HttpMethod;
     httpParameters  = "NO PARAMETERS";
     httpParameters  = "Id = " + model.Id +
                       "\nName = " + model.Name +
                       "\nType = " + model.Type +
                       "\nDescription = " + model.Description +
                       "\nPrice = " + model.Price;
 }
コード例 #18
0
        public IActionResult Create(ServiceViewModel model)
        {
            if (ModelState.IsValid)
            {
                var service = _mapper.Map <ServiceViewModel, Service>(model);
                service.AddedBy = _admin.Fullname;

                _serviceRepository.CreateService(service);

                return(RedirectToAction("index"));
            }

            return(View(model));
        }
コード例 #19
0
        public ServiceControl()
        {
            _serviceDataContext                       = new ServiceViewModel();
            _serviceDataContext.Services              = new ObservableCollection <Service>();
            _serviceDataContext.SaveServiceCommand    = new SaveServiceCommand(InsertService);
            _serviceDataContext.DeleteServiceCommand  = new DeleteServiceCommand(DeleteService);
            _serviceDataContext.EditServiceCommand    = new EditServiceCommand(EditService);
            _serviceDataContext.UpdateServiceCommand  = new UpdateServiceCommand(UpdateService);
            _serviceDataContext.AddToOfferCommand     = new AddToOfferCommand(AddToOffer);
            _serviceDataContext.ExportServicesCommand = new ExportServicesCommand(ExportServices);


            InitializeComponent();
            this.DataContext = _serviceDataContext;
        }
コード例 #20
0
        public ActionResult EditService(ServiceViewModel model)
        {
            if (ModelState.IsValid)
            {
                var service = seviceService.GetById(model.Id);

                service.Name = model.Name;

                seviceService.UpdateService(service);

                return(RedirectToAction("Service", "Admin"));
            }

            return(View(model));
        }
コード例 #21
0
        public JsonResult Delete(ServiceViewModel model)
        {
            int deleteIndex = 0;


            try
            {
                deleteIndex = ServiceManager.DeleteService(model.ServiceId);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
            return(deleteIndex > 0 ? Reload() : ErroResult("Failed to Delete"));
        }
コード例 #22
0
        public IActionResult EditService(int id)
        {
            var userServices = _userService.GetUserService(id);

            var service = new ServiceViewModel
            {
                ServiceDescription = userServices.ServiceDescription,
                ServiceId          = userServices.ServiceId,
                UserId             = userServices.UserProfileId,
                ServiceName        = userServices.ServiceName,
                UserI = userServices.UserId
            };

            return(View(service));
        }
コード例 #23
0
        public void ServiceOpeningTimesMessage_Returns_First_Session_Of_Two_On_Same_Day_Closed_Today()
        {
            var clock   = new StaticClock(DayOfWeek.Friday, 12, 30);
            var service = new ServiceViewModel(clock)
            {
                OpenAllHours = false,
                RotaSessions = new[]
                {
                    THURSDAY_AFTERNOON_SESSION,
                    THURSDAY_MORNING_SESSION
                }
            };

            Assert.AreEqual("Opens Thursday: 08:30 until 11:00", service.ServiceOpeningTimesMessage);
        }
        public List <ServiceViewModel> MapGetAllServicesByBankIdToViewModel(List <Service> model)
        {
            var servisesViewModel = new List <ServiceViewModel>();

            if (model != null)
            {
                foreach (var request in model)
                {
                    ServiceViewModel viewModel = Mapper.Map <ServiceViewModel>(request);

                    servisesViewModel.Add(viewModel);
                }
            }
            return(servisesViewModel);
        }
コード例 #25
0
        public IActionResult Edit(int?id)
        {
            ServiceViewModel serviceViewModel = new ServiceViewModel()
            {
                Service         = new Models.Service(),
                ServiceTypeList = _context.ServiceType.GetAll()
            };


            if (id != null)
            {
                serviceViewModel.Service = _context.Service.Get(id.GetValueOrDefault());
            }
            return(View(serviceViewModel));
        }
コード例 #26
0
        public void OpeningTimes_Multiple_Rota_Sessions_Time_After_All_Returns_Closed()
        {
            var clock   = new StaticClock(DayOfWeek.Thursday, 18, 00);
            var service = new ServiceViewModel(clock)
            {
                OpenAllHours = false,
                RotaSessions = new[]
                {
                    THURSDAY_MORNING_SESSION,
                    THURSDAY_AFTERNOON_SESSION
                },
            };

            Assert.AreEqual("Closed", service.CurrentStatus);
        }
コード例 #27
0
        public IActionResult Upsert(int?id)
        {
            ServiceVM = new ServiceViewModel()
            {
                Service       = new Models.Service(),
                CategoryList  = _unitOfWork.Category.GetCategoryListForDropDown(),
                FrequencyList = _unitOfWork.Frequency.GetFrequencyListForDropDown(),
            };
            if (id != null)
            {
                ServiceVM.Service = _unitOfWork.Service.Get(id.GetValueOrDefault());
            }

            return(View(ServiceVM));
        }
コード例 #28
0
        public IActionResult Save(ServiceViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                if (_dataManager.Services.SaveService(viewModel.Service))
                {
                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError(nameof(viewModel.Service.CategoryId), "Услуга с такими данными уже существует");
                ModelState.AddModelError(nameof(viewModel.Service.Name), "Услуга с такими данными уже существует");
            }

            return(View(viewModel));
        }
コード例 #29
0
        public ActionResult Delete(ServiceViewModel viewModel)
        {
            try
            {
                var service = _dbContext.Services.Single(v => v.Id == viewModel.Id);
                _dbContext.Services.Remove(service);
                _dbContext.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Delete"));
            }
        }
コード例 #30
0
        public ActionResult DeleteConfirmed(int id, int customerId, int machineId)
        {
            Service service = db.Services.Include("FileData").SingleOrDefault(x => x.Id == id);

            ServiceViewModel vm = new ServiceViewModel
            {
                Id   = service.Id,
                Name = service.Name
            };

            db.FileDatas.Remove(service.FileData);
            db.Services.Remove(service);
            db.SaveChanges();
            return(RedirectToAction("Details", "Machines", new { id = machineId, customerId = customerId }));
        }
コード例 #31
0
        public ActionResult Create(int? id)
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var user = _systemService.GetUserAndRole(0, userName);
            if (user == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (user.StockServiceR == 0)
            {
                return RedirectToAction("Index", "Home");
            }

            var item = new WAMS_ITEMS_SERVICE();

            if (id.HasValue)
            {
                item = _service.GetByKey(id.Value);
            }

            var model = new ServiceViewModel
            {
                Id = item.Id,
                vIDServiceItem = item.vIDServiceItem,
                vServiceItemName = item.vServiceItemName,
                bUnitID = item.bUnitID,
                bCategoryID = item.bCategoryID,
                bPositionID = item.bPositionID,
                bWeight = item.bWeight,
                vAccountCode = item.vAccountCode,
                Timestamp = item.Timestamp,
                UserLogin = user,
                Categories = new SelectList(_systemService.CategoryStockList(8), "Id", "Name"),
                Units = new SelectList(_systemService.UnitStockList(8), "Id", "Name"),
                Positions = new SelectList(_systemService.PositionStockList(), "Id", "Name")
            };

            return View(model);
        }
コード例 #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
        /// </summary>
        public MainWindowViewModel(IBackupSetService backupSetService, IMessageBoxService messageBoxService, IUIVisualizerService uiVisualizerService)
        {
            Argument.IsNotNull(() => backupSetService);
            Argument.IsNotNull(() => uiVisualizerService);
            Argument.IsNotNull(() => messageBoxService);

            _log.Info("In MainWindowViewModel constructor");

            _backupSetService = backupSetService;
            _uiVisualizerService = uiVisualizerService;
            _messageBoxService = messageBoxService;

            ServiceSettings = new ServiceViewModel();

            Themes = new[] { "Dark", "Light" };
            CurrentThemeNumber = 0;

            AddBackupSet = new Command(OnAddBackupSetExecute);
            EditBackupSet = new Command(OnEditBackupSetExecute, OnEditBackupSetCanExecute);
            RemoveBackupSet = new Command(OnRemoveBackupSetCollectionExecute, OnRemoveBackupSetCollectionCanExecute);

            OpenLogDirectoryCommand = new Command(OnShowLogDirectoryCommand);
            ShowAboutDialogCommand = new Command(() => _uiVisualizerService.ShowDialog(new AboutViewModel()));
            ToggleThemeCommand = new Command(() =>
                                                    {
                                                        CurrentThemeNumber++;
                                                        if(CurrentThemeNumber > Themes.Length - 1)
                                                        {
                                                            CurrentThemeNumber = 0;
                                                        }
                                                        RaiseThemeChanged(Themes[CurrentThemeNumber]);
                                                    });
            FilterAllBackupsCommand = new Command(() => FilterBackupSets());
            FilterOverdueBackupsCommand = new Command(() => FilterBackupSets(OVERDUE));
            FilterErrorBackupsCommand = new Command(() => FilterBackupSets(ERROR));

        

            Initialize();
        }
コード例 #33
0
 public ActionResult Index()
 {
     var userName = System.Web.HttpContext.Current.User.Identity.Name;
     var user = this._systemService.GetUserAndRole(0, userName);
     if (user == null) return RedirectToAction("Index", "Login");
     if (user.StockServiceR == 0) return RedirectToAction("Index", "Home");
     var model = new ServiceViewModel
     {
         UserLogin = user,
         Stores = new SelectList(_systemService.StoreList(), "Id", "Name"),
         Categories = new SelectList(_systemService.CategoryStockList(0), "Id", "Name")
     };
     return View(model);
 }
コード例 #34
0
        public ActionResult LoadDataList(int page, int size, string code, string name, int store, int category, string enable)
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var totalRecord = _service.ListConditionCount(page, size, code, name, store, category, enable);
            var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size);
            var totalPages = Convert.ToInt32(Math.Ceiling(totalTemp));
            var model = new ServiceViewModel
            {
                UserLogin = _systemService.GetUserAndRole(0, userName),
                ServiceList = _service.ListCondition(page, size, code, name, store, category, enable),
                TotalRecords = Convert.ToInt32(totalRecord),
                TotalPages = totalPages,
                CurrentPage = page,
                PageSize = size
            };

            return PartialView("_ServicePartial", model);
        }
コード例 #35
0
        private JsonResult CreateData(ServiceViewModel model)
        {
            if (_service.ExistedName(model.vServiceItemName))
            {
                return Json(new { result = Constants.Duplicate });
            }

            try
            {
                var item = new WAMS_ITEMS_SERVICE
                    {
                        vIDServiceItem = model.vIDServiceItem,
                        vServiceItemName = model.vServiceItemName,
                        vDescription = model.vDescription,
                        bCategoryID = model.bCategoryID,
                        bUnitID = model.bUnitID,
                        bPositionID = model.bPositionID,

                        // bSupplierID = viewModel.bSupplierID,
                        vStockType = "Service",
                        iEnable = true,
                        bWeight = model.bWeight,
                        vAccountCode = model.vAccountCode,
                        dCreated = DateTime.Now,
                        StoreId = model.StoreId
                    };

                _service.Insert(item);

                return Json(new { result = Constants.Success });
            }
            catch (Exception e)
            {
                Log.Error("Create New Service!", e);
                return Json(new { result = Constants.UnSuccess });
            }
        }
コード例 #36
0
        private JsonResult EditData(ServiceViewModel model)
        {
            var item = _service.GetByKey(model.Id);
            if (!Convert.ToBase64String(model.Timestamp).Equals(Convert.ToBase64String(item.Timestamp)))
            {
                return Json(new { result = Constants.DataJustChanged });
            }

            if (item.vServiceItemName != model.vServiceItemName)
            {
                if (_service.ExistedName(model.vServiceItemName))
                {
                    return Json(new { result = Constants.Duplicate });
                }
            }

            try
            {
                item.vServiceItemName = model.vServiceItemName;
                item.vDescription = model.vDescription;
                item.bCategoryID = model.bCategoryID;
                item.bUnitID = model.bUnitID;
                item.bPositionID = model.bPositionID;
                item.bWeight = model.bWeight;
                item.vAccountCode = model.vAccountCode;
                item.dModified = DateTime.Now;
                _service.Update(item);

                return Json(new { result = Constants.Success });
            }
            catch (Exception e)
            {
                Log.Error("Update Service!", e);
                return Json(new { result = Constants.UnSuccess });
            }
        }
コード例 #37
0
        public ActionResult Create(ServiceViewModel model)
        {
            if (model.V3 != true)
            {
                return Json(new { result = Constants.UnSuccess });
            }

            return model.Id == 0 ? CreateData(model) : EditData(model);
        }