示例#1
0
 public IActionResult AddColor(AddColorModel addColorModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Color colorModel = ColorHelper.BindColorModel(addColorModel);
             if (!string.IsNullOrWhiteSpace(addColorModel.ColorId) && DBHelper.ParseInt64(addColorModel.ColorId) <= 0)
             {
                 long colorId = iColor.AddColor(colorModel);
                 if (colorId > 0)
                 {
                     return(Ok(ResponseHelper.Success(MessageConstants.ColorAdded)));
                 }
                 else if (colorId == ReturnCode.AlreadyExist.GetHashCode())
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.ColorExists)));
                 }
                 else
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.ColorNotAdded)));
                 }
             }
             else
             {
                 long colorId = iColor.UpdateColor(colorModel);
                 if (colorId > 0)
                 {
                     return(Ok(ResponseHelper.Success(MessageConstants.ColorUpdated)));
                 }
                 else if (colorId == ReturnCode.AlreadyExist.GetHashCode())
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.ColorExists)));
                 }
                 else
                 {
                     return(Ok(ResponseHelper.Error(MessageConstants.ColorNotUpdated)));
                 }
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }