Beispiel #1
0
        public CreateOrUpdateDerLayoutResponse CreateOrUpdateDerLayout(CreateOrUpdateDerLayoutRequest request)
        {
            var response = new CreateOrUpdateDerLayoutResponse();
            try
            {
                if (request.Id > 0)
                {
                    var derLayout = DataContext.DerLayouts.Single(x => x.Id == request.Id);
                    derLayout.IsActive = request.IsActive;
                    derLayout.Title = request.Title;
                    DataContext.Entry(derLayout).State = EntityState.Modified;

                }
                else
                {
                    DataContext.DerLayouts.Add(new DerLayout() { IsActive = request.IsActive, Title = request.Title, IsDeleted = false });
                }

                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message = "DER Layout has been added successfully";
            }
            catch (Exception exception)
            {
                response.Message = exception.Message;
            }

            return response;
        }
Beispiel #2
0
        public ActionResult Create(CreateDerLayoutViewModel viewModel)
        {
            var request = new CreateOrUpdateDerLayoutRequest();
            request.Id = viewModel.Id;
            request.IsActive = viewModel.IsActive;
            request.Title = viewModel.Title;
            var response = _derService.CreateOrUpdateDerLayout(request);
            if (response.IsSuccess)
            {
                return RedirectToAction("Index");
            }

            return View(viewModel);
        }