public async Task <IActionResult> ShowPurchaseOrder(string id)
        {
            PurchaseOrder obj = await _context.PurchaseOrder
                                .Include(x => x.vendor)
                                .Include(x => x.purchaseOrderLine).ThenInclude(x => x.product)
                                .Include(x => x.branch)
                                .SingleOrDefaultAsync(x => x.purchaseOrderId.Equals(id));

            obj.totalOrderAmount    = obj.purchaseOrderLine.Sum(x => x.totalAmount);
            obj.totalDiscountAmount = obj.purchaseOrderLine.Sum(x => x.discountAmount);
            _context.Update(obj);

            return(View(obj));
        }
        public async Task <IActionResult> Edit(string id, [Bind("shipmentLineId,shipmentId,branchId,warehouseId,productId,qty,qtyShipment,qtyInventory,createdAt")] ShipmentLine shipmentLine)
        {
            if (id != shipmentLine.shipmentLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shipmentLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShipmentLineExists(shipmentLine.shipmentLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["branchId"]    = new SelectList(_context.Branch, "branchId", "branchId", shipmentLine.branchId);
            ViewData["productId"]   = new SelectList(_context.Product, "productId", "productId", shipmentLine.productId);
            ViewData["shipmentId"]  = new SelectList(_context.Shipment, "shipmentId", "shipmentId", shipmentLine.shipmentId);
            ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseId", shipmentLine.warehouseId);
            return(View(shipmentLine));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("NoteID,Title,Content,CID")] Note note)
        {
            if (id != note.NoteID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(note);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NoteExists(note.NoteID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CID"] = new SelectList(_context.Clients, "ClientID", "ClientID", note.CID);
            return(View(note));
        }
Пример #4
0
        public async Task <IActionResult> Edit(string id, [Bind("productId,productCode,productName,description,barcode,serialNumber,productType,uom,createdAt")] Product product)
        {
            if (id != product.productId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.productId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Пример #5
0
        public async Task <IActionResult> Edit(int id, [Bind("BlogId,Url")] Blog blog)
        {
            if (id != blog.BlogId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlogExists(blog.BlogId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }
Пример #6
0
        public async Task <IActionResult> Edit(string id, [Bind("opportunityLineId,opportunityId,activityId,startDate,endDate,description,createdAt")] OpportunityLine opportunityLine)
        {
            if (id != opportunityLine.opportunityLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(opportunityLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OpportunityLineExists(opportunityLine.opportunityLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["activityId"]    = new SelectList(_context.Activity, "activityId", "activityName", opportunityLine.activityId);
            ViewData["opportunityId"] = new SelectList(_context.Opportunity, "opportunityId", "opportunityName", opportunityLine.opportunityId);
            return(View(opportunityLine));
        }
Пример #7
0
        public async Task <IActionResult> Edit(string id, [Bind("receivingId,purchaseOrderId,receivingNumber,receivingDate,vendorId,vendorDO,vendorInvoice,branchId,warehouseId,HasChild,createdAt")] Receiving receiving)
        {
            if (id != receiving.receivingId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(receiving);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReceivingExists(receiving.receivingId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["branchId"]        = new SelectList(_context.Branch, "branchId", "branchName", receiving.branchId);
            ViewData["purchaseOrderId"] = new SelectList(_context.PurchaseOrder, "purchaseOrderId", "purchaseOrderNumber", receiving.purchaseOrderId);
            ViewData["vendorId"]        = new SelectList(_context.Vendor, "vendorId", "vendorName", receiving.vendorId);
            ViewData["warehouseId"]     = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", receiving.warehouseId);
            return(View(receiving));
        }
Пример #8
0
        public async Task <IActionResult> Edit(int id, [Bind("ContactId,OwnerID,Name,Address,City,State,Zip,Email,Status")] Contact contact)
        {
            if (id != contact.ContactId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactExists(contact.ContactId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
        public async Task <IActionResult> Edit(string id, [Bind("customerLineId,jobTitle,customerId,firstName,lastName,middleName,nickName,gender,salutation,mobilePhone,officePhone,fax,personalEmail,workEmail,createdAt")] CustomerLine customerLine)
        {
            if (id != customerLine.customerLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerLineExists(customerLine.customerLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["customerId"] = new SelectList(_context.Customer, "customerId", "customerId", customerLine.customerId);
            return(View(customerLine));
        }
Пример #10
0
        public async Task <IActionResult> Edit(string id, [Bind("opportunityId,opportunityName,description,stageId,accountExecutiveId,customerId,estimatedRevenue,estimatedClosingDate,probability,ratingId,HasChild,createdAt")] Opportunity opportunity)
        {
            if (id != opportunity.opportunityId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(opportunity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OpportunityExists(opportunity.opportunityId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["accountExecutiveId"] = new SelectList(_context.AccountExecutive, "accountExecutiveId", "accountExecutiveName", opportunity.accountExecutiveId);
            ViewData["customerId"]         = new SelectList(_context.Customer, "customerId", "customerName", opportunity.customerId);
            ViewData["ratingId"]           = new SelectList(_context.Rating, "ratingId", "ratingName", opportunity.ratingId);
            ViewData["stageId"]            = new SelectList(_context.Stage, "stageId", "stageName", opportunity.stageId);
            return(View(opportunity));
        }
Пример #11
0
        public async Task <IActionResult> Edit(string id, [Bind("stageId,stageName,description,colorHex,createdAt")] Stage stage)
        {
            if (id != stage.stageId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(stage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StageExists(stage.stageId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(stage));
        }
        public async Task <IActionResult> Edit(string id, [Bind("purchaseOrderLineId,purchaseOrderId,productId,qty,price,discountAmount,totalAmount,createdAt")] PurchaseOrderLine purchaseOrderLine)
        {
            if (id != purchaseOrderLine.purchaseOrderLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(purchaseOrderLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PurchaseOrderLineExists(purchaseOrderLine.purchaseOrderLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["productId"]       = new SelectList(_context.Product, "productId", "productId", purchaseOrderLine.productId);
            ViewData["purchaseOrderId"] = new SelectList(_context.PurchaseOrder, "purchaseOrderId", "purchaseOrderId", purchaseOrderLine.purchaseOrderId);
            return(View(purchaseOrderLine));
        }
Пример #13
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,DueDate,Attributes,Priority,AssignedClientID,EmployeeID")] Project project)
        {
            if (id != project.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AssignedClientID"] = new SelectList(_context.Clients, "ClientID", "BusinessName");
            ViewData["EmployeeID"]       = new SelectList(_context.Employees, "EmpID", "FullName");
            return(View(project));
        }
Пример #14
0
        public async Task <IActionResult> Edit(string id, [Bind("customerId,customerName,description,size,street1,street2,city,province,country,HasChild,createdAt")] Customer customer)
        {
            if (id != customer.customerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.customerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Edit(string id, [Bind("transferOutLineId,transferOutId,productId,qty,qtyInventory,createdAt")] TransferOutLine transferOutLine)
        {
            if (id != transferOutLine.transferOutLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(transferOutLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TransferOutLineExists(transferOutLine.transferOutLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["productId"]     = new SelectList(_context.Product, "productId", "productId", transferOutLine.productId);
            ViewData["transferOutId"] = new SelectList(_context.TransferOut, "transferOutId", "transferOutId", transferOutLine.transferOutId);
            return(View(transferOutLine));
        }
Пример #16
0
        public async Task <IActionResult> Edit(string id, [Bind("transferInId,transferOrderId,transferInNumber,transferInDate,description,branchIdFrom,warehouseIdFrom,branchIdTo,warehouseIdTo,HasChild,createdAt")] TransferIn transferIn)
        {
            if (id != transferIn.transferInId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(transferIn);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TransferInExists(transferIn.transferInId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["transferOrderId"] = new SelectList(_context.TransferOrder, "transferOrderId", "transferOrderNumber", transferIn.transferOrderId);
            ViewData["branchIdFrom"]    = new SelectList(_context.Branch, "branchId", "branchName");
            ViewData["warehouseIdFrom"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName");
            ViewData["branchIdTo"]      = new SelectList(_context.Branch, "branchId", "branchName");
            ViewData["warehouseIdTo"]   = new SelectList(_context.Warehouse, "warehouseId", "warehouseName");
            return(View(transferIn));
        }
        public async Task <IActionResult> Edit(string id, [Bind("receivingLineId,receivingId,branchId,warehouseId,productId,qty,qtyReceive,qtyInventory,createdAt")] ReceivingLine receivingLine)
        {
            if (id != receivingLine.receivingLineId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(receivingLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReceivingLineExists(receivingLine.receivingLineId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["branchId"]    = new SelectList(_context.Branch, "branchId", "branchName", receivingLine.branchId);
            ViewData["productId"]   = new SelectList(_context.Product, "productId", "productCode", receivingLine.productId);
            ViewData["receivingId"] = new SelectList(_context.Receiving, "receivingId", "receivingNumber", receivingLine.receivingId);
            ViewData["warehouseId"] = new SelectList(_context.Warehouse, "warehouseId", "warehouseName", receivingLine.warehouseId);
            return(View(receivingLine));
        }
Пример #18
0
        public async Task <IActionResult> Edit(string id, [Bind("branchId,warehouseId,warehouseName,description,street1,street2,city,province,country,createdAt")] Warehouse warehouse)
        {
            if (id != warehouse.warehouseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(warehouse);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WarehouseExists(warehouse.warehouseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(warehouse));
        }
Пример #19
0
        public async Task <IActionResult> Edit(string id, [FromForm] ApplicationUser applicationUser)
        {
            _logger.LogInformation(LoggingEvents.UpdateItem, "Update ApplicationUser: {id}", id);

            if (id != applicationUser.Id)
            {
                _logger.LogWarning(LoggingEvents.UpdateItemNotFound, "Update ApplicationUser: {id}", id);

                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //super admin should always have access to Roles
                    applicationUser.ApplicationUserRole = applicationUser.isSuperAdmin ? true : applicationUser.ApplicationUserRole;

                    _context.Update(applicationUser);
                    await _context.SaveChangesAsync();

                    ApplicationUser currentUserLogin = await _userManager.GetUserAsync(User);

                    await _netCoreService.UpdateRoles(applicationUser, currentUserLogin);
                }
                catch (Exception ex)
                {
                    _logger.LogError(LoggingEvents.UpdateItem, "Update ApplicationUser: {id}. Error: {Error}", id, ex.Message);

                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(applicationUser));
        }
        public async Task <IActionResult> Edit(int id, [Bind("NoteId,Title,Content,EID")] EmployeeNote employeeNote)
        {
            if (id != employeeNote.NoteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employeeNote);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeNoteExists(employeeNote.NoteId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employeeNote));
        }
Пример #21
0
        public async Task <IActionResult> PostPurchaseOrderLine([FromBody] PurchaseOrderLine purchaseOrderLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            PurchaseOrder purchaseOrder = await _context.PurchaseOrder.Where(x => x.purchaseOrderId.Equals(purchaseOrderLine.purchaseOrderId)).FirstOrDefaultAsync();

            if (purchaseOrder.purchaseOrderStatus == PurchaseOrderStatus.Completed)
            {
                return(Json(new { success = false, message = "Error. Can not edit [Completed] order" }));
            }

            purchaseOrderLine.totalAmount = (decimal)purchaseOrderLine.qty * purchaseOrderLine.price;

            if (purchaseOrderLine.purchaseOrderLineId == string.Empty)
            {
                purchaseOrderLine.purchaseOrderLineId = Guid.NewGuid().ToString();
                _context.PurchaseOrderLine.Add(purchaseOrderLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Add new data success." }));
            }
            else
            {
                _context.Update(purchaseOrderLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Edit data success." }));
            }
        }
Пример #22
0
        public async Task <IActionResult> Edit(int id, [Bind("EmpID,FirstName,LastName,Email,Phone,EnumRoles")] Employee employee)
        {
            if (id != employee.EmpID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.EmpID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
Пример #23
0
        public async Task <IActionResult> Edit(int id, [Bind("ClientID,BusinessName,Email,Phone,FirstName,LastName,DisplayName")] Client client)
        {
            if (id != client.ClientID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.ClientID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Пример #24
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,DueDate,Attributes,Priority")] Project project)
        {
            if (id != project.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
        public async Task <IActionResult> Edit(string id, [Bind("accountExecutiveId,accountExecutiveName,description,phone,email,street1,street2,city,province,country,systemUserId,createdAt")] AccountExecutive accountExecutive)
        {
            if (id != accountExecutive.accountExecutiveId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accountExecutive);
                    await _context.SaveChangesAsync();
                }
                catch (Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException)
                {
                    if (!AccountExecutiveExists(accountExecutive.accountExecutiveId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountExecutive));
        }
Пример #26
0
        public async Task <IActionResult> Edit(string id, [Bind("transferOrderId,isIssued,isReceived,transferOrderStatus,transferOrderNumber,transferOrderDate,description,picName,branchIdFrom,warehouseIdFrom,branchIdTo,warehouseIdTo,HasChild,createdAt")] TransferOrder transferOrder)
        {
            if (id != transferOrder.transferOrderId)
            {
                return(NotFound());
            }

            if ((TransferOrderStatus)TempData["TransferOrderStatus"] == TransferOrderStatus.Completed)
            {
                TempData["StatusMessage"] = "Error. Can not edit [Completed] order.";
                return(RedirectToAction(nameof(Edit), new { id = transferOrder.transferOrderId }));
            }

            if (transferOrder.transferOrderStatus == TransferOrderStatus.Completed)
            {
                TempData["StatusMessage"] = "Error. Can not edit status to [Completed].";
                return(RedirectToAction(nameof(Edit), new { id = transferOrder.transferOrderId }));
            }

            if (transferOrder.isIssued == true ||
                transferOrder.isReceived == true)
            {
                TempData["StatusMessage"] = "Error. Can not edit [Open] order that already process the goods issue or goods receive.";
                return(RedirectToAction(nameof(Edit), new { id = transferOrder.transferOrderId }));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    transferOrder.warehouseFrom = await _context.Warehouse.Include(x => x.branch).SingleOrDefaultAsync(x => x.warehouseId.Equals(transferOrder.warehouseIdFrom));

                    transferOrder.branchFrom = transferOrder.warehouseFrom.branch;

                    transferOrder.warehouseTo = await _context.Warehouse.SingleOrDefaultAsync(x => x.warehouseId.Equals(transferOrder.warehouseIdTo));

                    transferOrder.branchTo = transferOrder.warehouseTo.branch;

                    _context.Update(transferOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TransferOrderExists(transferOrder.transferOrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(transferOrder));
        }
        public async Task <IActionResult> PostUploadProfilePicture(List <IFormFile> files)
        {
            try
            {
                var fileName = await _netcoreService.UploadFile(files, _env);

                //try to update the user profile pict
                ApplicationUser appUser = await _userManager.GetUserAsync(User);

                appUser.profilePictureUrl = "/uploads/" + fileName;
                _context.Update(appUser);
                _context.SaveChanges();
                return(Ok(fileName));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new { message = ex.Message }));
            }
        }
Пример #28
0
        public async Task <IActionResult> PostTransferOrderLine([FromBody] TransferOrderLine transferOrderLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            TransferOrder transferOrder = await _context.TransferOrder.Where(x => x.transferOrderId.Equals(transferOrderLine.transferOrderId)).FirstOrDefaultAsync();

            if (transferOrder.transferOrderStatus == TransferOrderStatus.Completed)
            {
                return(Json(new { success = false, message = "Error. Can not edit [Completed] order" }));
            }

            if (transferOrder.isIssued == true)
            {
                return(Json(new { success = false, message = "Error. Can not edit [Open] order that already process the goods issue" }));
            }

            if (transferOrder.isReceived == true)
            {
                return(Json(new { success = false, message = "Error. Can not edit [Open] order that already process the goods receive" }));
            }

            if (transferOrderLine.transferOrderLineId == string.Empty)
            {
                transferOrderLine.transferOrderLineId = Guid.NewGuid().ToString();
                _context.TransferOrderLine.Add(transferOrderLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Add new data success." }));
            }
            else
            {
                _context.Update(transferOrderLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Edit data success." }));
            }
        }
Пример #29
0
        public async Task <IActionResult> Edit(string id, [Bind("branchId,branchName,description,street1,street2,city,province,country,createdAt,isDefaultBranch")] Branch branch)
        {
            if (id != branch.branchId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(branch);
                    await _context.SaveChangesAsync();

                    if (branch.isDefaultBranch)
                    {
                        List <Branch> others = await _context.Branch.Where(x => !x.branchId.Equals(branch.branchId)).ToListAsync();

                        foreach (var item in others)
                        {
                            item.isDefaultBranch = false;
                            await _context.SaveChangesAsync();
                        }
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BranchExists(branch.branchId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(branch));
        }
Пример #30
0
        public async Task <IActionResult> PostVendorLine([FromBody] VendorLine vendorLine)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (vendorLine.vendorLineId == string.Empty)
            {
                vendorLine.vendorLineId = Guid.NewGuid().ToString();
                _context.VendorLine.Add(vendorLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Add new data success." }));
            }
            else
            {
                _context.Update(vendorLine);
                await _context.SaveChangesAsync();

                return(Json(new { success = true, message = "Edit data success." }));
            }
        }