Пример #1
0
        public object Post([FromBody] DesignationModel model)
        {
            var output = new ResponseDetail();

            try
            {
                if (ModelState.IsValid)
                {
                    var designationDetail = Mapper.Map <Designation>(model);

                    var count = _designationService.CheckExistingDesignation(model.DesignationName);
                    if (!count)
                    {
                        _designationService.CreateDesignation(designationDetail);
                        output.Success = true;
                        output.Message = "Designtion added successfully!";
                    }
                    else
                    {
                        output.Success = false;
                        output.Message = "Designation already exists!";
                    }
                    return(output);
                }
                output.Success = false;
                return(output);
            }
            catch (Exception ex)
            {
                output.Success = false;
                output.Message = ex.Message;
                return(output);
            }
        }