public ReturnModel UpdateadminDetails(addAdminmodel updateAdmin) { ReturnModel retModel = new ReturnModel(); var Data = _dbcontext.superAdmin.FirstOrDefault(x => x.superAdminemail.ToLower().Equals(updateAdmin.superAdminemail.ToLower())); if (Data != null) { Data.superAdminemail = updateAdmin.superAdminemail; Data.superAdminname = updateAdmin.superAdminname; Data.superAdminusername = updateAdmin.superAdminusername; Data.superAdminPassword = updateAdmin.superAdminPassword; Data.IsUpdated = true; Data.UpdatedDateTime = DateTime.UtcNow; _dbcontext.superAdmin.Update(Data); var Isupdated = _dbcontext.SaveChanges(); if (Isupdated == 1) { superAdmin superadmin = new superAdmin { superAdminemail = updateAdmin.superAdminemail, superAdminname = updateAdmin.superAdminname, superAdminusername = updateAdmin.superAdminusername, superAdminPassword = updateAdmin.superAdminPassword, }; retModel.message = "Successfully update Super Admin"; retModel.statusCode = HttpStatusCode.OK; } else { retModel.message = "can't update Super Admin"; retModel.statusCode = HttpStatusCode.OK; } } return(retModel); }
public ReturnModel superAdminmodels(addAdminmodel details) { ReturnModel retModel = new ReturnModel(); try { var isExist = _dbcontext.superAdmin.FirstOrDefault(x => x.superAdminemail.ToLower().Equals(details.superAdminemail.ToLower())); if (isExist != null) { retModel.message = "Super Admin Already Exists"; retModel.statusCode = HttpStatusCode.BadRequest; } else { superAdmin superadmin = new superAdmin { superAdminId = details.superAdminId, superAdminemail = details.superAdminemail, superAdminname = details.superAdminname, superAdminusername = details.superAdminusername, superAdminPassword = details.superAdminPassword, IsActive = true, IsDeleted = false, IsUpdated = false, CreateDateTime = DateTime.UtcNow, DeletedDateTime = null, UpdatedDateTime = null }; _dbcontext.superAdmin.Add(superadmin); var isSaved = _dbcontext.SaveChanges(); if (isSaved > 0) { retModel.message = "Successfully Added New Super Admin"; retModel.statusCode = HttpStatusCode.OK; } else { retModel.message = "Can't add due to technical error"; retModel.statusCode = HttpStatusCode.InternalServerError; } } } catch (Exception ex) { retModel.message = ex.Message.ToString(); retModel.statusCode = HttpStatusCode.InternalServerError; } return(retModel); }