public IHttpActionResult Save(MasterBin data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _binService.Save(data); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void Save(MasterReaderModule data) { var institutionId = _securityService.GetCurrentInstitutionId(); if (data.ReaderModuleId == 0) { data.InstitutionId = institutionId; } _readerModuleRepository.Save(data); _readerModuleRepository.Commit(); if (data.Bins == null || data.Bins.Count() == 0) { var count = 1; for (var i = 1; i <= data.NoOfStack; i++) { for (var j = 1; j <= data.NoOfRow; j++) { var binCode = data.ReaderModuleCode + count.ToString("00"); var bin = new MasterBin() { BinCode = binCode, EmptyDistance = data.DefaultBinEmptyDistance, ReaderModuleId = data.ReaderModuleId, StackNo = i, RowNo = j, InstitutionId = institutionId }; _binService.Save(bin); count++; } } } else { _binService.Save(data.Bins.ToList()); } }