Inheritance: KnowYourTurf.Core.ViewModel
Ejemplo n.º 1
0
 public ActionResult AddEdit(ViewModel input)
 {
     var equipment = input.EntityId > 0 ? _repository.Find<Equipment>(input.EntityId) : new Equipment();
     var model = new EquipmentViewModel
     {
         Equipment = equipment
     };
     return PartialView("EquipmentAddUpdate", model);
 }
Ejemplo n.º 2
0
 public ActionResult Display(ViewModel input)
 {
     var equipment = _repository.Find<Equipment>(input.EntityId);
     var model = new EquipmentViewModel
     {
         Equipment = equipment,
         AddEditUrl = UrlContext.GetUrlForAction<EquipmentController>(x => x.AddEdit(null)) + "/" + equipment.EntityId
     };
     return PartialView("EquipmentView", model);
 }
Ejemplo n.º 3
0
        public ActionResult Save(EquipmentViewModel input)
        {
            var equipment = input.Equipment.EntityId > 0 ? _repository.Find<Equipment>(input.Equipment.EntityId) : new Equipment();
            equipment.Name = input.Equipment.Name;
            equipment.TotalHours = input.Equipment.TotalHours;
            if (input.DeleteImage)
            {
                _uploadedFileHandlerService.DeleteFile(equipment.ImageUrl);
                equipment.ImageUrl = string.Empty;
            }

            var serverDirectory = "/CustomerPhotos/" + _httpContextAbstractor.GetCompanyIdFromIdentity() + "/Equipment";
            equipment.ImageUrl = _uploadedFileHandlerService.GetUploadedFileUrl(serverDirectory, equipment.Name);
            var crudManager = _saveEntityService.ProcessSave(equipment);
            crudManager = _uploadedFileHandlerService.SaveUploadedFile(serverDirectory, equipment.Name, crudManager);
            var notification = crudManager.Finish();
            return Json(notification, "text/plain");
        }