Пример #1
0
        public async Task <IActionResult> Edit(string id, [Bind("TruckId,AcquisitionDate,PlantId,DriverEmployeeId,DriverName,Make,Model,Year,Type,RegCounty,Vin,Tonnage,LicPlateRenewal,RegFee,TruckNumber,Inactive,InactiveReason")] Truck truck)
        {
            if (id != truck.TruckId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Plant plt = new Plant();
                    plt = await _context.Plants.FindAsync(truck.PlantId);

                    truck.AssignedPlant = new Plant();
                    truck.AssignedPlant = plt;

                    Employee emp = new Employee();
                    emp = (from e in _context.Employee
                           where e.EmployeeId == truck.DriverEmployeeId && e.PlantId == truck.PlantId select e).FirstOrDefault();

                    if (emp != null)
                    {
                        truck.DriverName = emp.FirstName + " " + emp.LastName;
                    }
                    else
                    {
                        truck.DriverName = null;
                        _context.Update(truck);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction("Edit", "Trucks", new { Id = truck.TruckId }));
                    }
                    _context.Update(truck);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TruckExists(truck.TruckId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(truck));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("PlantId,PlantName,PlantManagerEmail,PlantManagerTxtNum,PlantManager,Address,Address2,City,State,ZipCode,County,PrintCompletedOrders,Phone1,Phone2,PhoneType1,PhoneType2")] Plant plant)
        {
            if (id != plant.PlantId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(plant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlantExists(plant.PlantId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", new { Id = plant.PlantId }));
            }
            return(View(plant));
        }
        public async Task <IActionResult> Edit(int id, [Bind("FuneralHomeContactId,FuneralHomeId,FirstName,LastName,NickName,FullName,Email,Phone1,Phone2,Phone3,PhoneType1,PhoneType2,PhoneType3,Spouse,ShowPrices,ContactRole,Interests,Photo")] FuneralHomeContact funeralHomeContact)
        {
            if (id == 0)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                funeralHomeContact.FullName = funeralHomeContact.FirstName + " " + funeralHomeContact.LastName;
                try
                {
                    _context.Update(funeralHomeContact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FuneralHomeContactExists(funeralHomeContact.FuneralHomeContactId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "FuneralHomes", new { Id = funeralHomeContact.FuneralHomeId }));
            }
            return(View(funeralHomeContact));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,Description,Ovation,Decoration,Legacy,Size,Price,ProductCode,AllowedToSelectId,UpChargeForLegacy,UpChargeAmount,ProductCategory,Color,Color1,Color2,Comments,PhotoImage")] 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));
        }
        public async Task <IActionResult> Edit(int id, [Bind("EmployeeId,CanDoFollowUps,Title,FirstName,LastName,MiddleName,Address,City,State,ZipCode,County,Email,Phone1,PhoneType1,Active,PhotoImage,PlantId,SelectedAnswer")] Employee employee)
        {
            if (id != employee.EmployeeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (employee.SelectedAnswer == 1)
                {
                    employee.Active = "Yes";
                }
                else
                {
                    employee.Active = "No";
                }

                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.EmployeeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PlantId"] = new SelectList(_context.Plants, "PlantId", "PlantId", employee.PlantId);
            return(View(employee));
        }
        public async Task <IActionResult> Edit(int id, [Bind("InteractionId,Date,Nature,Notes,FollowUpDate,Reason,Completed,Outcome,FuneralHomeId,SelectedAnswer")] Interaction interaction)
        {
            if (id != interaction.InteractionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (interaction.SelectedAnswer == 1)
                {
                    interaction.Completed = "Yes";
                }
                else
                {
                    interaction.Completed = "No";
                }

                try
                {
                    _context.Update(interaction);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InteractionExists(interaction.InteractionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "FuneralHomes", new { Id = interaction.FuneralHomeId }));
            }
            return(View(interaction));
        }
Пример #7
0
        public async Task <IActionResult> Edit(int id, [Bind("CemetaryId,Name,Address,City,State,ZipCode,County," +
                                                             "Phone1,PhoneType1,PlantId,PlantName,Directions,Lattitude,Longitude,Map,UseCoordinates")] Cemetary cemetary)
        {
            if (id != cemetary.CemetaryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (cemetary.PlantId != 0)
                {
                    Plant plt = await _context.Plants.FindAsync(cemetary.PlantId);

                    cemetary.PlantName = plt.PlantName;
                }
                try
                {
                    _context.Update(cemetary);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CemetaryExists(cemetary.CemetaryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cemetary));
        }
        public async Task <IActionResult> Edit(int id, [Bind("FuneralHomeId,ParentFuneralHomeId,PlantId," +
                                                             "Name,Address,Address2,City,State,ZipCode,County,Email,Website,Phone1,Phone2,Phone3," +
                                                             "PhoneType1,PhoneType2,PhoneType3,IsParent,ParentName,PlantName")] FuneralHome funeralHome)
        {
            //if (id != funeralHome.FuneralHomeId)
            if (id == 0)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (_context.ParentFuneralHomes.Count() > 1)
                {
                    ParentFuneralHome parentFuneralHome = await _context.ParentFuneralHomes.FindAsync(funeralHome.ParentFuneralHomeId);

                    if (funeralHome.IsParent && parentFuneralHome == null)
                    {
                        initParentList(funeralHome);
                        addParent(funeralHome);
                    }
                    else
                    {
                        initParentList(funeralHome);
                    }

                    funeralHome.ParentName = parentFuneralHome.ParentFuneralhomeName;
                }
                else
                {
                    ParentFuneralHome parentFuneralHome = await _context.ParentFuneralHomes.FindAsync(funeralHome.ParentFuneralHomeId);

                    if (funeralHome.IsParent && parentFuneralHome == null)
                    {
                        addParent(funeralHome);
                    }
                    if (parentFuneralHome != null)
                    {
                        funeralHome.ParentName = parentFuneralHome.ParentFuneralhomeName;
                    }
                }

                if (funeralHome.PlantId != 0)
                {
                    Plant plt = await _context.Plants.FindAsync(funeralHome.PlantId);

                    funeralHome.PlantName = plt.PlantName;
                }

                try
                {
                    _context.Update(funeralHome);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FuneralHomeExists(funeralHome.FuneralHomeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(funeralHome));
        }
Пример #9
0
        public async Task <IActionResult> Edit(int id, [Bind("VaultOrderId,strFuneralDate,FuneralDate," +
                                                             "CemetaryTime,strCemeteryTime,Location,GraveLocationSection,OrderingPlantId," +
                                                             "OrderingPlantName,DeliveringPlantId,DeliveringPlantName,ZipCode,FuneralHomeId," +
                                                             "FuneralHomeContactId,FuneralDirector,NewFuneralDirector,CemetaryId,Status,Category,VaultId," +
                                                             "VenetianCarapace,TentWith6Chairs,ExtraChairs,RegisterStand,MilitarySetup,AwningOverCasket," +
                                                             "Fdrequest,VaultOrderNotes,PlantId,ContactId," +
                                                             "Salutation,FirstName,MiddleName,LastName,FullName,Suffix,BornDate,DiedDate")] VaultOrder vaultOrder)
        {
            if (id != vaultOrder.VaultOrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (vaultOrder.OrderingPlantId != 0)
                {
                    var ordPlant = new Plant();
                    ordPlant = await _context.Plants.FindAsync(vaultOrder.OrderingPlantId);

                    vaultOrder.OrderingPlantName = ordPlant.PlantName;
                }
                if (vaultOrder.DeliveringPlantId != 0)
                {
                    var delPlant = new Plant();
                    delPlant = await _context.Plants.FindAsync(vaultOrder.DeliveringPlantId);

                    vaultOrder.DeliveringPlantName = delPlant.PlantName;
                }

                if (vaultOrder.FuneralHomeId != 0)
                {
                    vaultOrder.funeralhome = (from f in _context.FuneralHomes.Where(i => i.FuneralHomeId == vaultOrder.FuneralHomeId)
                                              select f.Name).FirstOrDefault();
                }

                if (vaultOrder.FuneralHomeContactId != 0)
                {
                    vaultOrder.FuneralDirector = (from f in _context.FuneralHomeContacts.Where(i => i.FuneralHomeContactId == vaultOrder.FuneralHomeContactId)
                                                  select f.FullName).FirstOrDefault();
                }

                try
                {
                    _context.Update(vaultOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VaultOrderExists(vaultOrder.VaultOrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FuneralHomeId"] = new SelectList(_context.FuneralHomes, "FuneralHomeId", "FuneralHomeId", vaultOrder.FuneralHomeId);

            return(View(vaultOrder));
        }