Exemple #1
0
        public bool UpdatePrivledges(PharmaBusinessObjects.Master.Privledge privledge)
        {
            using (PharmaDBEntities context = new PharmaDBEntities())
            {
                try
                {
                    int result = 0;

                    Privledges priv = context.Privledges.Where(p => p.PrivledgeId == privledge.PrivledgeId).FirstOrDefault();

                    if (priv != null)
                    {
                        priv.PriviledgeName = privledge.PrivledgeName;
                        priv.Status         = privledge.Status;
                        priv.ControlName    = privledge.ControlName;
                        priv.ModifiedBy     = this.LoggedInUser.Username;
                        priv.ModifiedOn     = DateTime.Now;
                    }

                    result = context.SaveChanges();

                    return(result > 0);
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                {
                    throw ex;
                }
            }
        }
Exemple #2
0
        public bool AddPrivledge(PharmaBusinessObjects.Master.Privledge privledge)
        {
            using (PharmaDBEntities context = new PharmaDBEntities())
            {
                try
                {
                    int result = 0;

                    if (context.Privledges.Any(p => p.PriviledgeName.ToLower() == privledge.PrivledgeName.ToLower()))
                    {
                        throw new Exception("Privledge already exists");
                    }

                    Privledges priv = new Privledges()
                    {
                        PriviledgeName = privledge.PrivledgeName,
                        Status         = privledge.Status,
                        ControlName    = privledge.ControlName,
                        CreatedBy      = this.LoggedInUser.Username,
                        CreatedOn      = DateTime.Now
                    };

                    context.Privledges.Add(priv);
                    result = context.SaveChanges();

                    return(result > 0);
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                {
                    throw ex;
                }
            }
        }
 public bool UpdatePrivledge(PharmaBusinessObjects.Master.Privledge p)
 {
     return(new UserBiz(this.LoggedInUser).UpdatePrivledge(p));
 }