예제 #1
0
        public IHttpActionResult PutCustomers(int id, Customers customers)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customers.Id)
            {
                return(BadRequest());
            }

            db.Entry(customers).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public bool IsPurchaseOperationSuccess(PurchaseOperationInfo purchaseOperationInformation)
        {
            dbContext.PurchaseOperationInformations.Add(purchaseOperationInformation);
            var isSuccess = dbContext.SaveChanges() > 0;

            IsStockUpdated(purchaseOperationInformation.PurchaseItems, purchaseOperationInformation.BranchId);

            return(isSuccess);
        }
예제 #3
0
        public bool IsSalesOperationSuccess(SalesOperationInfo opi)
        {
            dbContext.SalesOperationInformations.Add(opi);
            var isSuccess = dbContext.SaveChanges() > 0;

            IsStockUpdated(opi.SalesItems, opi.BranchId);

            return(isSuccess);
        }
예제 #4
0
 public bool Add(ExpenseCategory category)
 {
     _expenseCategoryDb.ExpenseCategories.Add(category);
     if (_expenseCategoryDb.SaveChanges() > 0)
     {
         return(true);
     }
     return(false);
 }
예제 #5
0
        public bool IsBranchSaved(Branch branch)
        {
            dbContext.Branches.Add(branch);
            var isAdded = dbContext.SaveChanges();

            if (isAdded > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
파일: ItemGetway.cs 프로젝트: ashiqqs/POS
        public bool IsItemSaved(Item item)
        {
            dbContext.Items.Add(item);
            var isAdded = dbContext.SaveChanges();

            if (isAdded > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #7
0
        public bool IsExpenseItemSaved(ExpenseItem expenseItem)
        {
            dbContext.ExpenseItems.Add(expenseItem);
            var isAdded = dbContext.SaveChanges();

            if (isAdded > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #8
0
        private void CreateEditions()
        {
            var defaultEdition = _context.Editions.IgnoreQueryFilters().FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName);

            if (defaultEdition == null)
            {
                defaultEdition = new Edition {
                    Name = EditionManager.DefaultEditionName, DisplayName = EditionManager.DefaultEditionName
                };
                _context.Editions.Add(defaultEdition);
                _context.SaveChanges();

                /* Add desired features to the standard edition, if wanted... */
            }
        }
        public bool IsExpenseOperationSuccess(ExpenseOperationInfo exoi)
        {
            dbContext.ExpenseOperationInformations.Add(exoi);
            var isSuccess = dbContext.SaveChanges() > 0;

            return(isSuccess);
        }
예제 #10
0
        public bool Update(Employee employee)
        {
            PosDbContext db = new PosDbContext();

            db.Employees.Attach(employee);
            db.Entry(employee).State = EntityState.Modified;
            return(db.SaveChanges() > 0);
        }
예제 #11
0
파일: PartyGetway.cs 프로젝트: ashiqqs/POS
        public bool IsPartyUpdated(Party party)
        {
            PosDbContext db = new PosDbContext();

            db.Parties.Attach(party);
            db.Entry(party).State = EntityState.Modified;
            return(db.SaveChanges() > 0);
        }
예제 #12
0
        public bool Update(ExpenseCategory category)
        {
            PosDbContext db = new PosDbContext();

            db.ExpenseCategories.Attach(category);
            db.Entry(category).State = EntityState.Modified;
            return(db.SaveChanges() > 0);
        }
예제 #13
0
        public bool Update(Organization organization)
        {
            PosDbContext db = new PosDbContext();

            db.Organizations.Attach(organization);
            db.Entry(organization).State = EntityState.Modified;
            return(db.SaveChanges() > 0);
        }
예제 #14
0
        public void Create()
        {
            new DefaultEditionCreator(_context).Create();
            new DefaultLanguagesCreator(_context).Create();
            new HostRoleAndUserCreator(_context).Create();
            new DefaultSettingsCreator(_context).Create();

            _context.SaveChanges();
        }
예제 #15
0
        private void AddLanguageIfNotExists(ApplicationLanguage language)
        {
            if (_context.Languages.IgnoreQueryFilters().Any(l => l.TenantId == language.TenantId && l.Name == language.Name))
            {
                return;
            }

            _context.Languages.Add(language);
            _context.SaveChanges();
        }
예제 #16
0
        public bool Update(ItemCategory category)
        {
            PosDbContext db = new PosDbContext();

            db.ItemCategories.Attach(category);
            db.Entry(category).State = EntityState.Modified;
            bool isUpdate = db.SaveChanges() > 0;

            return(isUpdate);
        }
예제 #17
0
        public Invoice InsertTransactionDetails(CartItem transactionDetails, List <SalesDetails> invoiceItemDetails)
        {
            var invoice = new Invoice()
            {
                EmployeeId = GetUserByUserId(1),
                DateOfSale = DateTime.Now,
                Discount   = Convert.ToDouble(transactionDetails.Discount.Split(" ")[0]),
                Vat        = Convert.ToDouble(transactionDetails.Vat.Split(" ")[0])
            };

            _posDbContext.Add <Invoice>(invoice);
            _posDbContext.SaveChanges();

            var invoiceItems = new List <ItemInSalesTransaction>();

            foreach (var invoiceItem in invoiceItemDetails)
            {
                var invoiceTransactionItem = new ItemInSalesTransaction()
                {
                    InvoiceReferenceNumber = invoice,
                    ProductReferenceId     = _posDbContext.Products.Where(p => p.ProductId == Convert.ToInt32(invoiceItem.ProductId)).SingleOrDefault(),
                    ConsumedQuantity       = Convert.ToInt32(invoiceItem.ConsumedQuantity),
                    TotalPrice             = Convert.ToDouble(invoiceItem.TotalPrice.Split(" ")[0])
                };

                invoiceItems.Add(invoiceTransactionItem);

                var product = GetPosStoreItemById(Convert.ToInt32(invoiceItem.ProductId));
                product.AvailableQuantity -= Convert.ToInt32(invoiceItem.ConsumedQuantity);
                _posDbContext.SaveChanges();
            }

            _posDbContext.SalesTransactions.AddRange(invoiceItems);
            _posDbContext.SaveChanges();

            return(invoice);
        }
예제 #18
0
        public Response <Documentos> Post(InvoiceType Documento)
        {
            FactElectronica Fact = new FactElectronica();
            var             Res  = Fact.GeneraDocumentoElectronicoXML(Documento);

            if (Res.CodResponse == "0")
            {
                using (PosDbContext context = new PosDbContext())
                {
                    context.Add(Res.Data);
                    //Guardamos los cambios
                    context.SaveChanges();
                }
            }
            Res.Data.IdTramaNavigation.Documentos = null;
            return(Res);
        }
        public ActionResult Edit(Customer aCustomer)
        {
            PosDbContext db = new PosDbContext();
            Customer     existingCustomer = db.Customers.Find(aCustomer.id);

            if (existingCustomer != null)
            {
                existingCustomer.Name    = aCustomer.Name;
                existingCustomer.Email   = aCustomer.Email;
                existingCustomer.Address = aCustomer.Address;
            }
            if (db.SaveChanges() > 0)
            {
                ViewBag.message = "Customer Updated Sucessfully";
            }

            return(View(existingCustomer));
        }
예제 #20
0
        private void CreateDefaultTenant()
        {
            // Default tenant

            var defaultTenant = _context.Tenants.IgnoreQueryFilters().FirstOrDefault(t => t.TenancyName == AbpTenantBase.DefaultTenantName);

            if (defaultTenant == null)
            {
                defaultTenant = new Tenant(AbpTenantBase.DefaultTenantName, AbpTenantBase.DefaultTenantName);

                var defaultEdition = _context.Editions.IgnoreQueryFilters().FirstOrDefault(e => e.Name == EditionManager.DefaultEditionName);
                if (defaultEdition != null)
                {
                    defaultTenant.EditionId = defaultEdition.Id;
                }

                _context.Tenants.Add(defaultTenant);
                _context.SaveChanges();
            }
        }
예제 #21
0
        public int Delete(int id)
        {
            int deleted = 0;

            using (var transaction = this.DbContext.Database.BeginTransaction())
            {
                try {
                    var discount = DbSet.Where(m => m.Id == id)
                                   .Include(m => m.Items)
                                   .ThenInclude(i => i.Details)
                                   .FirstOrDefault();
                    discount.FlagForDelete(IdentityService.Username, UserAgent);
                    foreach (var i in discount.Items)
                    {
                        i.FlagForDelete(IdentityService.Username, UserAgent);
                        foreach (var d in i.Details)
                        {
                            d.FlagForDelete(IdentityService.Username, UserAgent);
                        }
                    }

                    var stores = DbContext.DiscountStores.Where(x => x.DiscountId == id);
                    foreach (var s in stores)
                    {
                        s.FlagForDelete(IdentityService.Username, UserAgent);
                    }
                    deleted = DbContext.SaveChanges();
                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw new Exception(e.Message);
                }
            }


            return(deleted);
        }
예제 #22
0
 public bool Add(Employee employee)
 {
     _employeeDb.Employees.Add(employee);
     return(_employeeDb.SaveChanges() > 0);
 }
예제 #23
0
 public bool Add(Organization organization)
 {
     _organizationDb.Organizations.Add(organization);
     return(_organizationDb.SaveChanges() > 0);
 }
예제 #24
0
        private void CreateRolesAndUsers()
        {
            // Admin role

            var adminRole = _context.Roles.IgnoreQueryFilters().FirstOrDefault(r => r.TenantId == _tenantId && r.Name == StaticRoleNames.Tenants.Admin);

            if (adminRole == null)
            {
                adminRole = _context.Roles.Add(new Role(_tenantId, StaticRoleNames.Tenants.Admin, StaticRoleNames.Tenants.Admin)
                {
                    IsStatic = true
                }).Entity;
                _context.SaveChanges();
            }

            // Grant all permissions to admin role

            var grantedPermissions = _context.Permissions.IgnoreQueryFilters()
                                     .OfType <RolePermissionSetting>()
                                     .Where(p => p.TenantId == _tenantId && p.RoleId == adminRole.Id)
                                     .Select(p => p.Name)
                                     .ToList();

            var permissions = PermissionFinder
                              .GetAllPermissions(new PosAuthorizationProvider())
                              .Where(p => p.MultiTenancySides.HasFlag(MultiTenancySides.Tenant) &&
                                     !grantedPermissions.Contains(p.Name))
                              .ToList();

            if (permissions.Any())
            {
                _context.Permissions.AddRange(
                    permissions.Select(permission => new RolePermissionSetting
                {
                    TenantId  = _tenantId,
                    Name      = permission.Name,
                    IsGranted = true,
                    RoleId    = adminRole.Id
                })
                    );
                _context.SaveChanges();
            }

            // Admin user

            var adminUser = _context.Users.IgnoreQueryFilters().FirstOrDefault(u => u.TenantId == _tenantId && u.UserName == AbpUserBase.AdminUserName);

            if (adminUser == null)
            {
                adminUser                  = User.CreateTenantAdminUser(_tenantId, "*****@*****.**");
                adminUser.Password         = new PasswordHasher <User>(new OptionsWrapper <PasswordHasherOptions>(new PasswordHasherOptions())).HashPassword(adminUser, "123qwe");
                adminUser.IsEmailConfirmed = true;
                adminUser.IsActive         = true;

                _context.Users.Add(adminUser);
                _context.SaveChanges();

                // Assign Admin role to admin user
                _context.UserRoles.Add(new UserRole(_tenantId, adminUser.Id, adminRole.Id));
                _context.SaveChanges();
            }
        }
예제 #25
0
파일: PartyGetway.cs 프로젝트: ashiqqs/POS
 public bool IsPartySaved(Party party)
 {
     dbContext.Parties.Add(party);
     return(dbContext.SaveChanges() > 0);
 }
예제 #26
0
 public int Save()
 {
     return(_context.SaveChanges());
 }
예제 #27
0
 public void SubmitOrder(Order order)
 {
     _Context.Orders.Add(order);
     order.OrderItems.ForEach(oi => _Context.OrderItems.Add(oi));
     _Context.SaveChanges();
 }
예제 #28
0
 public bool Add(ItemCategory category)
 {
     _itemCategoryDb.ItemCategories.Add(category);
     return(_itemCategoryDb.SaveChanges() > 0);
 }
예제 #29
0
 public bool Add(Purchase purchase)
 {
     _posDbContext.Purchases.Add(purchase);
     return(_posDbContext.SaveChanges() > 0);
 }
예제 #30
0
        private void CreateHostRoleAndUsers()
        {
            // Admin role for host

            var adminRoleForHost = _context.Roles.IgnoreQueryFilters().FirstOrDefault(r => r.TenantId == null && r.Name == StaticRoleNames.Host.Admin);

            if (adminRoleForHost == null)
            {
                adminRoleForHost = _context.Roles.Add(new Role(null, StaticRoleNames.Host.Admin, StaticRoleNames.Host.Admin)
                {
                    IsStatic = true, IsDefault = true
                }).Entity;
                _context.SaveChanges();
            }

            // Grant all permissions to admin role for host

            var grantedPermissions = _context.Permissions.IgnoreQueryFilters()
                                     .OfType <RolePermissionSetting>()
                                     .Where(p => p.TenantId == null && p.RoleId == adminRoleForHost.Id)
                                     .Select(p => p.Name)
                                     .ToList();

            var permissions = PermissionFinder
                              .GetAllPermissions(new PosAuthorizationProvider())
                              .Where(p => p.MultiTenancySides.HasFlag(MultiTenancySides.Host) &&
                                     !grantedPermissions.Contains(p.Name))
                              .ToList();

            if (permissions.Any())
            {
                _context.Permissions.AddRange(
                    permissions.Select(permission => new RolePermissionSetting
                {
                    TenantId  = null,
                    Name      = permission.Name,
                    IsGranted = true,
                    RoleId    = adminRoleForHost.Id
                })
                    );
                _context.SaveChanges();
            }

            // Admin user for host

            var adminUserForHost = _context.Users.IgnoreQueryFilters().FirstOrDefault(u => u.TenantId == null && u.UserName == AbpUserBase.AdminUserName);

            if (adminUserForHost == null)
            {
                var user = new User
                {
                    TenantId         = null,
                    UserName         = AbpUserBase.AdminUserName,
                    Name             = "admin",
                    Surname          = "admin",
                    EmailAddress     = "*****@*****.**",
                    IsEmailConfirmed = true,
                    IsActive         = true
                };

                user.Password = new PasswordHasher <User>(new OptionsWrapper <PasswordHasherOptions>(new PasswordHasherOptions())).HashPassword(user, "123qwe");
                user.SetNormalizedNames();

                adminUserForHost = _context.Users.Add(user).Entity;
                _context.SaveChanges();

                // Assign Admin role to admin user
                _context.UserRoles.Add(new UserRole(null, adminUserForHost.Id, adminRoleForHost.Id));
                _context.SaveChanges();

                _context.SaveChanges();
            }
        }