public async Task <int> SaveOtherDocumentDetail(OtherDocumentDetail otherDocumentDetail) { if (otherDocumentDetail.Id != 0) { _context.OtherDocumentDetails.Update(otherDocumentDetail); await _context.SaveChangesAsync(); return(otherDocumentDetail.Id); } else { await _context.OtherDocumentDetails.AddAsync(otherDocumentDetail); await _context.SaveChangesAsync(); return(otherDocumentDetail.Id); } }
public async Task <IActionResult> SaveOtherDocumentDetails(OtherDocumentInformationViewModel model) { try { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/OtherDocumentDetail", model.formFile); if (message == "success") { attachPath = fileName; } } OtherDocumentDetail otherDocumentDetail = new OtherDocumentDetail { Id = (int)model.otherId, gDInformationId = model.gDInformationId, documentTypeId = model.documentTypeId == 0 ? null : model.documentTypeId, typeName = model.typeName, description = model.description, modelName = model.modelName, price = model.price, quantity = model.quantity, attachment = attachPath }; int gdId = await otherDocumentService.SaveOtherDocumentDetail(otherDocumentDetail); return(Ok("Success")); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> SaveComputerInfo(ComputerInfoViewModel model) { string msg = "error"; try { if (!string.IsNullOrEmpty(model.model) || !string.IsNullOrEmpty(model.serialNo) || !string.IsNullOrEmpty(model.serviceCode) || !string.IsNullOrEmpty(Convert.ToString(model.districtId)) || !string.IsNullOrEmpty(Convert.ToString(model.thanaId))) { var user = await _userManager.FindByNameAsync(model.userName); string gdNumber = RandomString(6); GDInformation gDInformation = new GDInformation { ApplicationUserId = user.Id, gdFor = model.gdFor, gdDate = DateTime.Now, gdNumber = gdNumber, gDTypeId = model.gDTypeId, productTypeId = model.productTypeId, documentTypeId = model.documentTypeId == 0 ? null : model.documentTypeId, documentDescription = model.documentDescription, statusId = 1 }; int masterId = await lostAndFoundService.SaveGDInformation(gDInformation); if (model.gdFor == "OTHERS") { OtherPersonInformation otherPerson = new OtherPersonInformation { gDInformationId = masterId, nationalIdentityTypeId = model.nationalIdentityTypeId == 0 ? null : model.nationalIdentityTypeId, identityNo = model.identityNo, mobileNo = model.mobileNo }; int opi = await lostAndFoundService.SaveOtherPersonInformation(otherPerson); } OtherDocumentDetail otherDocumentDetail = new OtherDocumentDetail { gDInformationId = masterId, modelName = model.model, serialNo = model.serialNo, productNumber = model.serviceCode, colorsId = model.colorId, price = model.price, currency = model.currency }; IndentifyInfo indentifyInfo = new IndentifyInfo { gDInformationId = masterId, identifySign = model.identificationMark, colorsId = model.colorId }; SpaceAndTime spaceAndTime = new SpaceAndTime { gDInformationId = masterId, districtId = model.districtId, thanaId = model.thanaId, village = model.village, placeDetails = model.addressDetails, lafDate = model.date, lafTime = model.time }; await otherDocumentService.SaveOtherDocumentDetail(otherDocumentDetail); await lostAndFoundService.SaveIndentifyInfo(indentifyInfo); await lostAndFoundService.SaveSpaceAndTime(spaceAndTime); msg = gdNumber; } return(Ok(msg)); } catch (Exception e) { throw e; } }