//Add update Holding Master public JsonResponse AddUpdate(HoldingNature model) { try { // If model.ID == 0 the data goes to the Add part. if (!IsExsits(model.HNCode, model.ID)) { if (model.ID == 0) { //Insert HoldingNature Table model.CreatedOn = DateTime.Now; model.CreatedBy = GetUserID(); _context.Set <HoldingNature>().Add(model); int i = _context.SaveChanges(); if (i != 0) { resp.Status = Constants.ResponseStatus.Success; resp.Message = Constants.Service.Data_insert_success; } else { resp.Status = Constants.ResponseStatus.Failed; } } // Else data goes to the Update part. else { resp.Message = Constants.Service.Data_Update_failed; var holdingNatureDetails = GetData(model.ID); //Update holdingNature Table if (holdingNatureDetails != null) { holdingNatureDetails.HNCode = model.HNCode; holdingNatureDetails.HoldingType = model.HoldingType; holdingNatureDetails.IsActive = model.IsActive; holdingNatureDetails.ModifiedOn = DateTime.Now; holdingNatureDetails.ModifiedBy = GetUserID(); _context.Set <HoldingNature>().Update(holdingNatureDetails); int i = _context.SaveChanges(); if (i != 0) { resp.Status = Constants.ResponseStatus.Success; resp.Message = Constants.Service.Data_Update_success; } } } } else { resp.Status = Constants.ResponseStatus.Failed; resp.Message = "HNCode Name is already exists.."; } } catch (Exception ex) { resp.Message = Constants.Service.Common_message; throw ex; } return(resp); }
public HoldingNatureViewModel() { HoldingNature = new HoldingNature(); }