예제 #1
0
        public object DeleteSubCaste(SubCasteParam MP)
        {
            try
            {
                Tbl_Sub_Caste_Master objSubCaste = db.Tbl_Sub_Caste_Master.Where(r => r.SubCasteID == MP.SubCasteID).FirstOrDefault();

                if (objSubCaste.Status == 1)
                {
                    objSubCaste.Status = 0;
                }
                else
                {
                    objSubCaste.Status = 1;
                }

                db.SaveChanges();

                return(new Result()
                {
                    IsSucess = true, ResultData = "Sub Caste Updated Successfully!"
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
예제 #2
0
        public object SaveSubCaste(SubCasteParam MP)
        {
            try
            {
                string msg = "";
                if (MP.BtnStatus == "Save")
                {
                    var usercode = db.Tbl_Sub_Caste_Master.Where(r => r.SubCasteName == MP.SubCasteName.ToUpper()).FirstOrDefault();
                    if (usercode != null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Sub Caste Name Already Exists!"
                        });
                    }
                    Tbl_Sub_Caste_Master objSubCaste = new Tbl_Sub_Caste_Master();

                    objSubCaste.SubCasteName = MP.SubCasteName.ToUpper();
                    objSubCaste.CasteID      = MP.CasteID;
                    objSubCaste.CreatedBy    = MP.CreatedBy;
                    objSubCaste.CreatedDate  = DateTime.Now;
                    objSubCaste.Status       = 1;
                    db.Tbl_Sub_Caste_Master.Add(objSubCaste);
                    db.SaveChanges();
                    msg = "Sub Caste Saved Successfully!";
                }
                else
                {
                    Tbl_Sub_Caste_Master objSubCaste = db.Tbl_Sub_Caste_Master.Where(r => r.SubCasteID == MP.SubCasteID).FirstOrDefault();
                    var Data = db.Tbl_Sub_Caste_Master.Where(r => r.SubCasteName == MP.SubCasteName.ToUpper()).FirstOrDefault();
                    if (Data != null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Sub Caste Name Already Exists!"
                        });
                    }
                    objSubCaste.SubCasteName = MP.SubCasteName.ToUpper();
                    objSubCaste.CasteID      = MP.CasteID;
                    objSubCaste.SubCasteID   = MP.SubCasteID;
                    objSubCaste.ModifiedDate = DateTime.Now;
                    db.SaveChanges();
                    msg = "Sub Caste Updated Successfully!";
                }

                return(new Result()
                {
                    IsSucess = true, ResultData = msg
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }