public object DeleteMinority(MinorityParam MP) { try { Tbl_Minority_Master objminority = db.Tbl_Minority_Master.Where(r => r.MinorityID == MP.MinorityID).FirstOrDefault(); if (objminority.Status == 1) { objminority.Status = 0; } else { objminority.Status = 1; } db.SaveChanges(); return(new Result() { IsSucess = true, ResultData = "Minority Updated Successfully!" }); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }
public object SaveMinority(MinorityParam MP) { try { string msg = ""; if (MP.BtnStatus == "Save") { var usercode = db.Tbl_Minority_Master.Where(r => r.MinorityName == MP.MinorityName.ToUpper()).FirstOrDefault(); if (usercode != null) { return(new Error() { IsError = true, Message = "Minority Name Already Exists!" }); } Tbl_Minority_Master objMinority = new Tbl_Minority_Master(); objMinority.MinorityName = MP.MinorityName.ToUpper(); objMinority.CreatedBy = MP.CreatedBy; objMinority.CreatedDate = DateTime.Now; objMinority.Status = 1; db.Tbl_Minority_Master.Add(objMinority); db.SaveChanges(); msg = "Minority Saved Successfully!"; } else { Tbl_Minority_Master objMinority = db.Tbl_Minority_Master.Where(r => r.MinorityID == MP.MinorityID).FirstOrDefault(); var Data = db.Tbl_Minority_Master.Where(r => r.MinorityName == MP.MinorityName.ToUpper()).FirstOrDefault(); if (Data != null) { return(new Error() { IsError = true, Message = "Minority Name Already Exists!" }); } objMinority.MinorityName = MP.MinorityName.ToUpper(); objMinority.ModifiedDate = DateTime.Now; objMinority.MinorityID = MP.MinorityID; db.SaveChanges(); msg = "Minority Updated Successfully!"; } return(new Result() { IsSucess = true, ResultData = msg }); } catch (Exception ex) { return(new Error() { IsError = true, Message = ex.Message }); } }