public ActionResult Edit(OrganizationTypeModel model)
        {
            if (ModelState.IsValid)
            {
                bool has_error = false;

                var organization_service = CompositionRoot.Resolve <IOrganizationService>();

                if (!has_error)
                {
                    try {
                        var type = OrganizationTypeModelConverter.FromModel(model);
                        organization_service.UpdateType(type);
                    }
                    catch (DomainException e) {
                        ModelState.AddModelError("", e);
                        has_error = true;
                    }
                }

                if (!has_error)
                {
                    return(RedirectToAction("List"));
                }
            }
            return(View());
        }
 public static OrganizationType FromModel(OrganizationTypeModel model)
 {
     return(new OrganizationType {
         Id = model.Id,
         Caption = model.Caption
     });
 }
        public IActionResult Put(int id, [FromBody] OrganizationTypeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var response = organizationTypeService.Update(id, model);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(response.Message));
        }
        public IActionResult Post([FromBody] OrganizationTypeModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var response = organizationTypeService.Add(model);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(response.ReturnedId));
        }
        public ActionResponse Update(int id, OrganizationTypeModel organizationType)
        {
            using (var unitWork = new UnitOfWork(context))
            {
                ActionResponse response            = new ActionResponse();
                var            organizationTypeObj = unitWork.OrganizationTypesRepository.GetByID(id);
                if (organizationTypeObj == null)
                {
                    IMessageHelper mHelper = new MessageHelper();
                    response.Success = false;
                    response.Message = mHelper.GetNotFound("Organization Type");
                    return(response);
                }

                organizationTypeObj.TypeName = organizationType.TypeName;
                unitWork.Save();
                response.Message = "1";
                return(response);
            }
        }
 public ActionResponse Add(OrganizationTypeModel organizationType)
 {
     using (var unitWork = new UnitOfWork(context))
     {
         ActionResponse response = new ActionResponse();
         try
         {
             var newOrganizationType = unitWork.OrganizationTypesRepository.Insert(new EFOrganizationTypes()
             {
                 TypeName = organizationType.TypeName
             });
             response.ReturnedId = newOrganizationType.Id;
             unitWork.Save();
         }
         catch (Exception ex)
         {
             response.Success = false;
             response.Message = ex.Message;
         }
         return(response);
     }
 }
        public ActionResult Delete(OrganizationTypeModel model)
        {
            if (ModelState.IsValid)
            {
                bool has_error = false;

                var organization_service = CompositionRoot.Resolve <IOrganizationService>();
                try {
                    organization_service.DeleteType(model.Id);
                }
                catch (DomainException e) {
                    ModelState.AddModelError("", e);
                    has_error = true;
                }

                if (!has_error)
                {
                    return(RedirectToAction("List"));
                }
            }

            return(View());
        }