public ResultDTO Post([FromBody] OrganizationLevelEntity OrganizationLevel)
 {
     try
     {
         return(_OrganizationLevel.CreateOrganizationLevel(OrganizationLevel));
     }
     catch (Exception ex)
     {
         throw new ApiDataException(1000, "OrganizationLevel not found", HttpStatusCode.NotFound);
     }
 }
 public HttpResponseMessage Put([FromBody] OrganizationLevelEntity OrganizationLevel)
 {
     try
     {
         if (OrganizationLevel.OrganizationLevelId > 0)
         {
             var result = _OrganizationLevel.UpdateOrganizationLevel(OrganizationLevel.OrganizationLevelId, OrganizationLevel);
             return(Request.CreateResponse(HttpStatusCode.OK, result));
         }
     }
     catch (Exception ex)
     {
         throw new ApiDataException(1000, "OrganizationLevel not found", HttpStatusCode.NotFound);
     }
     return(Request.CreateResponse(HttpStatusCode.InternalServerError, "InternalServerError"));
 }
Example #3
0
        public ResultDTO UpdateOrganizationLevel(int OrganizationLevelId, OrganizationLevelEntity OrganizationLevelEntity)
        {
            var result = new ResultDTO {
                IsSuccess = false
            };

            if (OrganizationLevelEntity != null)
            {
                var isExist = _unitOfWork.OrganizationLevelRepository.GetManyQueryable(c => c.LevelName.ToLower() == OrganizationLevelEntity.LevelName.ToLower() && c.Parent == OrganizationLevelEntity.Parent && c.Code == OrganizationLevelEntity.Code).Count() > 0;
                if (!isExist)
                {
                    using (var scope = new TransactionScope())
                    {
                        var Orglevel = _unitOfWork.OrganizationLevelRepository.GetByID(OrganizationLevelId);
                        if (Orglevel != null)
                        {
                            Orglevel.LevelName  = OrganizationLevelEntity.LevelName;
                            Orglevel.Parent     = OrganizationLevelEntity.Parent;
                            Orglevel.CreatedBy  = OrganizationLevelEntity.CreatedBy;
                            Orglevel.ModifiedBy = OrganizationLevelEntity.ModifiedBy;
                            Orglevel.ModifiedOn = DateTime.Now;
                            Orglevel.IsActive   = OrganizationLevelEntity.IsActive;
                            Orglevel.Code       = OrganizationLevelEntity.Code;

                            _unitOfWork.OrganizationLevelRepository.Update(Orglevel);
                            _unitOfWork.Save();
                            scope.Complete();

                            result.IsSuccess = true;
                            result.Message   = "Updated Successfully";
                        }
                    }
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = "Level Name already exist";
                }
            }
            return(result);
        }