/* * Developer: Azeem Hassan * Date: 7-5-19 * Action: update vendor repo to database * Input: vendor repo * output: result */ public async Task <Boolean> Update(VendorContactPerson VendorToUpdate) { using (IDbConnection conn = Connection) { var result = await conn.UpdateAsync <VendorContactPerson>(VendorToUpdate); return(result); } }
/* * Developer: Azeem Hassan * Date: 7-5-19 * Action: creating new vendor repo to database * Input: vendor repo * output: result */ public async Task <string> Create(VendorContactPerson NewVendorRep) { using (IDbConnection conn = Connection) { var result = await conn.InsertAsync <VendorContactPerson>(NewVendorRep); return(result.ToString()); } }
public async Task <string> Update(int id, [FromBody] string value) { string UpdateResult = "Success"; bool UpdateProcessOutput = false; try { VendorContactPerson VendorToUpdate = JsonConvert.DeserializeObject <VendorContactPerson>(value); VendorToUpdate.contact_id = id; int updated_by = VendorToUpdate.updated_by; UpdateProcessOutput = await _VendorRepRepository.Update(VendorToUpdate); var eventModel = new EventModel(vendorEventTableName) { EventName = update_vendor_repo, EntityId = VendorToUpdate.vendor_id, RefrenceId = id, UserId = updated_by, EventNoteId = id }; await _eventRepo.AddEventAsync(eventModel); var userEvent = new EventModel(userEventTableName) { EventName = update_vendor_repo, EntityId = updated_by, RefrenceId = id, UserId = updated_by, EventNoteId = id }; await _eventRepo.AddEventAsync(userEvent); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in updating vendor with message" + ex.Message); UpdateResult = "Failed"; } if (!UpdateProcessOutput) { UpdateResult = "Creation failed due to reason: No specific reson"; } return(UpdateResult); }
public async Task <string> PostAsync([FromBody] string value) { string NewInsertionID = "0"; try { VendorContactPerson newVendorRep = JsonConvert.DeserializeObject <VendorContactPerson>(value); int created_by = newVendorRep.created_by; NewInsertionID = await _VendorRepRepository.Create(newVendorRep); var eventModel = new EventModel(vendorEventTableName) { EventName = create_vendor_repo, EntityId = newVendorRep.vendor_id, RefrenceId = Int32.Parse(NewInsertionID), UserId = created_by, EventNoteId = Int32.Parse(NewInsertionID) }; await _eventRepo.AddEventAsync(eventModel); var userEvent = new EventModel(userEventTableName) { EventName = create_vendor_repo, EntityId = created_by, RefrenceId = Convert.ToInt32(NewInsertionID), UserId = created_by, EventNoteId = Int32.Parse(NewInsertionID) }; await _eventRepo.AddEventAsync(userEvent); } catch (Exception ex) { var logger = _loggerFactory.CreateLogger("internal_error_log"); logger.LogInformation("Problem happened in making new vendor with message" + ex.Message); } return(NewInsertionID); }