Esempio n. 1
0
 public void Insert(DirectoryCategoryModel model)
 {
     try
     {
         var objToSave = new tblDirectoryCategory()
         {
             DirectoryCategoryId   = model.DirectoryCategoryId,
             DirectoryCategoryName = model.DirectoryCategoryName,
         };
         //objToSave.CreatedBy = Utility.GetCurrentLoginUser();
         objToSave.CreatedDate = DateTime.Now.ToShortDateString().ToString();
         ent.tblDirectoryCategories.Add(objToSave);
         ent.SaveChanges();
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 2
0
        public void Insert(DirectoryModel model)
        {
            var objToSave = new tblDirectoryItem()
            {
                DirectoryItemId        = model.DirectoryItemId,
                DirectoryItemName      = model.DirectoryItemName,
                DirectoryCategoryId    = model.DirectoryCategoryId,
                DirectorySubCategoryId = model.DirectorySubCategoryId,
                IssueDate     = model.IssueDate,
                Status        = model.Status,
                Specification = model.Specification
            };

            ent.tblDirectoryItems.Add(objToSave);
            ent.SaveChanges();
            var addDetail = new tblDirectoryDetail()
            {
                DirectoryDetailsId = model.DirectoryDetailsId,
                DirectoryItemId    = objToSave.DirectoryItemId,
                AddressState       = model.AddressState,
                AddressDistrict    = model.AddressDistrict,
                AddressPalika      = model.AddressPalika,
                AddressWard        = model.AddressWard,
                DirectoryPhone     = model.DirectoryPhone,
                PAN = model.PAN,
                VAT = model.VAT,
                ContactPersonName  = model.ContactPersonName,
                ContactPersonPhone = model.ContactPersonPhone,
                Details            = model.Details,
                Email     = model.Email,
                PhotoLogo = model.PhotoLogo
            };

            ent.tblDirectoryDetails.Add(addDetail);
            ent.SaveChanges();
        }
Esempio n. 3
0
        public bool InsertUpdateUserDetails(UserModel model)
        {
            try
            {
                using (var con = new DirectoryEntities())
                {
                    var userId = HttpContext.Current.User.Identity.GetUserId();
                    var user   = con.UsersDetails.Where(x => x.Id == model.Id || x.UserId == userId).FirstOrDefault();
                    if (user != null)
                    {
                        user.FullName  = model.FullName;
                        user.ContactNo = model.PhoneNo;
                        user.Email     = model.Email;
                        if (model.Image != null)
                        {
                            user.Image = model.Image;
                        }

                        con.Entry(user).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        UsersDetail usersDetail = new UsersDetail()
                        {
                            Id        = Guid.NewGuid(),
                            FullName  = model.FullName,
                            ContactNo = model.PhoneNo,
                            UserId    = userId,
                            Email     = model.Email,
                            Image     = model.Image,
                        };
                        con.UsersDetails.Add(usersDetail);
                    }

                    con.SaveChanges();
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public void Commit()
        {
            bool saveFailed;

            do
            {
                saveFailed = false;

                try
                {
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    saveFailed = true;

                    var entry = ex.Entries.Single();
                    entry.OriginalValues.SetValues(entry.GetDatabaseValues());
                }
            } while (saveFailed);
        }
        public bool InsertUpdateSubCategory(SubCategorySetupViewModel model)
        {
            try
            {
                using (var con = new DirectoryEntities())
                {
                    if (model.DirectorySubCategoryId > 0)
                    {
                        var record = con.tblDirectorySubCategories.Where(x => x.DirectorySubCategoryId == model.DirectorySubCategoryId).FirstOrDefault();
                        if (record != null)
                        {
                            record.DirectorySubCategoryId   = model.DirectorySubCategoryId;
                            record.DirectorySubCategoryName = model.DirectorySubCategoryName;
                            record.DirectoryCategoryId      = model.DirectoryCategoryId;
                            con.Entry(record).State         = System.Data.Entity.EntityState.Modified;
                        }
                    }
                    else
                    {
                        tblDirectorySubCategory subCategory = new tblDirectorySubCategory()
                        {
                            DirectorySubCategoryId   = model.DirectorySubCategoryId,
                            DirectorySubCategoryName = model.DirectorySubCategoryName,
                            DirectoryCategoryId      = model.DirectoryCategoryId
                        };
                        //subCategory.CreatedBy = Utility.GetCurrentLoginUser();
                        subCategory.CreatedDate = DateTime.Now.ToShortDateString().ToString();
                        con.tblDirectorySubCategories.Add(subCategory);
                    }
                    con.SaveChanges();

                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }