Esempio n. 1
0
        public bool Update(LookupModel model)
        {
            try
            {
                bool isSaved = false;

                if (!IsExist(model))
                {
                    using (var db = new HMSEntities())
                    {
                        WardDetail entity = db.WardDetails.Find(model.Id);

                        entity.Name        = model.Name;
                        entity.Description = model.Description;
                        entity.ModifiedOn  = DateTime.Now;
                        entity.ModifiedBy  = UserDetailSession.Id;

                        db.SaveChanges();

                        isSaved = true;
                    }
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public LookupModel GetById(Guid id)
        {
            try
            {
                LookupModel model = new LookupModel();
                using (var db = new HMSEntities())
                {
                    WardDetail entity = db.WardDetails.Find(id);
                    if (entity != null)
                    {
                        model.Id          = entity.Id;
                        model.Name        = entity.Name;
                        model.Description = entity.Description;
                        model.IsActive    = entity.IsActive;
                        model.IsDeleted   = entity.IsDeleted;
                        model.CreatedOn   = entity.CreatedOn;
                        model.CreatedBy   = entity.CreatedBy;
                        model.ModifiedOn  = entity.ModifiedOn;
                        model.ModifiedBy  = entity.ModifiedBy;
                    }
                }

                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public bool Create(LookupModel model)
        {
            try
            {
                bool isSaved = false;

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

                        entity.Name        = model.Name;
                        entity.Description = model.Description;
                        entity.IsActive    = true;
                        entity.IsDeleted   = false;
                        entity.CreatedOn   = DateTime.Now;
                        entity.CreatedBy   = UserDetailSession.Id;

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

                        isSaved = true;
                    }
                }


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