示例#1
0
        public void Update(DirectoryModel model)
        {
            var objToEdit = ent.tblDirectoryItems.Where(x => x.DirectoryItemId == model.DirectoryItemId).FirstOrDefault();

            objToEdit.DirectoryItemName      = model.DirectoryItemName;
            objToEdit.DirectoryCategoryId    = model.DirectoryCategoryId;
            objToEdit.DirectorySubCategoryId = model.DirectorySubCategoryId;
            objToEdit.IssueDate        = model.IssueDate;
            objToEdit.Status           = model.Status;
            objToEdit.Specification    = model.Specification;
            ent.Entry(objToEdit).State = System.Data.Entity.EntityState.Modified;
            ent.SaveChanges();

            var editDetail = ent.tblDirectoryDetails.Where(x => x.DirectoryItemId == model.DirectoryItemId).FirstOrDefault();

            editDetail.AddressState       = model.AddressState;
            editDetail.AddressDistrict    = model.AddressDistrict;
            editDetail.AddressPalika      = model.AddressPalika;
            editDetail.AddressWard        = model.AddressWard;
            editDetail.DirectoryPhone     = model.DirectoryPhone;
            editDetail.PAN                = model.PAN;
            editDetail.VAT                = model.VAT;
            editDetail.DirectoryPhone     = model.DirectoryPhone;
            editDetail.ContactPersonName  = model.ContactPersonName;
            editDetail.ContactPersonPhone = model.ContactPersonPhone;
            editDetail.Details            = model.Details;
            editDetail.Email              = model.Email;
            editDetail.PhotoLogo          = model.PhotoLogo;
            ent.Entry(editDetail).State   = System.Data.Entity.EntityState.Modified;
            ent.SaveChanges();
        }
示例#2
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);
            }
        }
示例#3
0
        public void Update(DirectoryCategoryModel model)
        {
            try
            {
                var objToEdit = ent.tblDirectoryCategories.Single(x => x.DirectoryCategoryId == model.DirectoryCategoryId);
                objToEdit.DirectoryCategoryId   = model.DirectoryCategoryId;
                objToEdit.DirectoryCategoryName = model.DirectoryCategoryName;

                //objToEdit.UpdatedBy = Utility.GetCurrentLoginUser();
                //objToEdit.UpdateDate = DateTime.Now.ToShortDateString().ToString();
                ent.Entry(objToEdit).State = System.Data.Entity.EntityState.Modified;
                ent.SaveChanges();
            }
            catch (Exception ex)
            {
                //Log.Error(string.Format("Error! on  Update InventoryItemCategoryData Data Auction  with error message: {0}",
                //    ex.Message));
                //Log.Error(string.Format("Error with exception: {0}", ex.StackTrace));
            }
        }
        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);
            }
        }