Exemplo n.º 1
0
        public object DeleteDesignation(DesignationParam MP)
        {
            try
            {
                Tbl_Designation_Master objdesignation = db.Tbl_Designation_Master.Where(r => r.DesignationID == MP.DesignationID).FirstOrDefault();

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

                db.SaveChanges();

                return(new Result()
                {
                    IsSucess = true, ResultData = "Designation Updated Successfully!"
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
Exemplo n.º 2
0
        public object SaveDesignation(DesignationParam MP)
        {
            try
            {
                string msg = "";
                if (MP.BtnStatus == "Save")
                {
                    var usercode = db.Tbl_Designation_Master.Where(r => r.Designation == MP.Designation.ToUpper()).FirstOrDefault();
                    if (usercode != null)
                    {
                        return(new Error()
                        {
                            IsError = true, Message = "Designation Name Already Exists!"
                        });
                    }
                    Tbl_Designation_Master objDesignation = new Tbl_Designation_Master();

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

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