Пример #1
0
        public ActionResult Edit(LocationDTO model)
        {
            try
            {

                _locationService.Save(model);

                return RedirectToAction("Index");
            }
            catch (DomainValidationException ve)
            {
                ve.DomainValidationErrors(ModelState);
                bind();
                return View();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                bind();
                return View();
            }
            return View();
        }
Пример #2
0
        public BasicResponse Save(LocationDTO dto)
        {
            var response = new BasicResponse();
            try
            {
                var entity = new Location
                {
                    Code = dto.Code,
                    Id = dto.Id,
                    Name = dto.Name,
                    Description = dto.Description,
                    StructureId =(LocationStructure) dto.LocationStructureId,
                    IsActive = true,
                };
                _locationRepository.Save(entity);
                response.Status = true;
                response.Info = "Success";

            }

            catch (Exception ex)
            {
                response.Status = false;
                if (ex is DomainValidationException)
                {
                    var dex = ex as DomainValidationException;
                    response.Info = dex.FormatException();
                }
                else
                {
                    response.Status = false;
                    response.Info = ex.Message;
                }

            }
            return response;
        }
Пример #3
0
        private LocationDTO Map(Location entity)
        {
            if (entity == null)
                return null;
            var dto = new LocationDTO
            {
                Code = entity.Code,
                Id = entity.Id,
                IsActive = entity.IsActive,
                Name = entity.Name,
                Description = entity.Description,
                LocationStructureId =(int) entity.StructureId,
                LocationStructureName = entity.StructureId.ToString(),

            };
            return dto;
        }