public async Task <IActionResult> AddUser(Person data) { try { var chkCode = await con.peoples.Where(c => c.code == data.code).AnyAsync(); if (chkCode == true) { return(Content("The user code is already exists")); } var chkCnin = await con.peoples.Where(c => c.cnic == data.cnic).AnyAsync(); if (chkCnin == true) { return(Content("The CNIC is already exists")); } var chkNumber = await con.peoples.Where(c => c.contactOne == data.contactOne).AnyAsync(); if (chkNumber == true) { return(Content("The contact number is already exists")); } int usrId = Convert.ToInt32(HttpContext.Session.GetInt32("usrId")); data.CreatedBy = usrId; data.perStatus = "Active"; data.CreatedDate = DateTime.Now; con.peoples.Add(data); await con.SaveChangesAsync(); Login login = new Login(); login.perId = data.perId; login.roleId = data.roleId; login.usrName = data.cnic; login.usrPassword = "******"; login.usrStatus = "Active"; con.logins.Add(login); await con.SaveChangesAsync(); return(Content("")); } catch (Exception) { return(Content("Data Not added")); } }
public async Task <IActionResult> AddOperation(Donation donation) { try { int usrId = Convert.ToInt32(HttpContext.Session.GetInt32("usrId")); donation.CreatedBy = usrId; donation.CreatedDate = DateTime.Now; con.donations.Add(donation); await con.SaveChangesAsync(); if (donation.dType == "Giver") { var msgboday = "Ghani Foundation has received " + donation.dAmount + " /-pkr. Thanks for trusting us."; msg.SendSMSTurab(donation.dNumber, msgboday); } else { var msgboday = "You have received " + donation.dAmount + " /-pkr from Ghani Foundation. Remember us in your prayers."; msg.SendSMSTurab(donation.dNumber, msgboday); } return(Content("")); } catch (Exception) { return(Content("Donation no added")); } }
public async Task <IActionResult> AddCountry(Country data) { try { var chkData = await con.countries.Where(c => c.cCode == data.cCode).AnyAsync(); if (chkData == true) { return(Content("The country code is already exist")); } else { data.CreatedDate = DateTime.Now; con.countries.Add(data); await con.SaveChangesAsync(); return(Content("")); } } catch (Exception) { return(Content("Data Not added")); } }