Exemplo n.º 1
0
        public bool Create(UserDetailModel model)
        {
            try
            {
                bool isSaved = false;

                if (!IsExist(model))
                {
                    using (var db = new HMSEntities())
                    {
                        UserDetail entity = new UserDetail();

                        entity.FullName       = model.FullName;
                        entity.Address        = model.Address;
                        entity.PhoneNumber    = model.PhoneNumber;
                        entity.DepartmentId   = Department.GetByName("OPD").Id;
                        entity.RoleCategoryId = RoleCategory.GetByName("Genaral").Id;
                        entity.UserName       = model.UserName;
                        entity.Password       = model.Password;
                        entity.IsActive       = true;
                        entity.IsDeleted      = false;
                        entity.CreatedOn      = DateTime.Now;
                        entity.CreatedBy      = UserDetailSession.Id;

                        db.UserDetails.Add(entity);
                        db.SaveChanges();

                        isSaved = true;
                    }
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }