Beispiel #1
0
        public ActionResult Adding(ClientWithAddressModel clientWithAddres)
        {
            var client = new Client
            {
                Symbol      = clientWithAddres.Symbol,
                Name        = clientWithAddres.Name,
                Email       = clientWithAddres.Email,
                PhoneNumber = clientWithAddres.PhoneNumber,
                Description = clientWithAddres.Description
            };

            var clientAddress = new ClientAddress
            {
                ClientSymbol = clientWithAddres.Symbol,
                Street       = clientWithAddres.Street,
                Number       = clientWithAddres.Number,
                ZipCode      = clientWithAddres.ZipCode,
                City         = clientWithAddres.City
            };

            using (var ctx = new ResuestServiceContext())
            {
                ctx.Clients.Add(client);
                ctx.ClientAddresses.Add(clientAddress);
                ctx.SaveChanges();
            }

            return(RedirectToAction("Index", "Clients"));
        }
Beispiel #2
0
        public ActionResult Closing(Guid id)
        {
            using (var ctx = new ResuestServiceContext())
            {
                var request = ctx.Requests.SingleOrDefault(r => r.Id == id);
                request.RequestStatus = RequestStatus.Zamkniety;
                request.ResolveDate   = DateTime.Now;
                ctx.SaveChanges();
            }

            return(RedirectToAction("Index", "Requests"));
        }
Beispiel #3
0
        public ActionResult Editing(EmployeeModel employeeModel)
        {
            if (!ModelState.IsValid)
            {
                return(Edit(employeeModel));
            }

            using (var ctx = new ResuestServiceContext())
            {
                var employee = ctx.Employees.SingleOrDefault(x => x.Identifier == employeeModel.Identifier);
                employee.FirstName = employeeModel.FirstName;
                employee.LastName  = employeeModel.LastName;
                ctx.SaveChanges();
            }

            return(RedirectToAction("Index", "Employees"));
        }
Beispiel #4
0
        public ActionResult Assigning(RequestEmployeesModel requestEmployeesModel)
        {
            using (var ctx = new ResuestServiceContext())
            {
                var employeesToRemove = ctx.EmployeeRequests.Where(e => e.RequestId == requestEmployeesModel.RequestId).AsEnumerable();
                ctx.EmployeeRequests.RemoveRange(employeesToRemove);
                var employeeRequests = requestEmployeesModel.Employees.Where(e => e.IsAssigned).Select(e => new EmployeeRequest
                {
                    RequestId          = requestEmployeesModel.RequestId,
                    EmployeeIdentifier = e.Identifier
                });
                ctx.EmployeeRequests.AddRange(employeeRequests);
                ctx.SaveChanges();
            }

            return(RedirectToAction("Index", "Requests"));
        }
Beispiel #5
0
        public ActionResult Editing(ClientWithAddressModel clientWithAddres)
        {
            using (var ctx = new ResuestServiceContext())
            {
                var client  = ctx.Clients.SingleOrDefault(x => x.Symbol == clientWithAddres.Symbol);
                var address = ctx.ClientAddresses.SingleOrDefault(x => x.ClientSymbol == clientWithAddres.Symbol);
                client.Name        = clientWithAddres.Name;
                client.Email       = clientWithAddres.Email;
                client.PhoneNumber = clientWithAddres.PhoneNumber;
                client.Description = clientWithAddres.Description;
                address.Street     = clientWithAddres.Street;
                address.Number     = clientWithAddres.Number;
                address.ZipCode    = clientWithAddres.ZipCode;
                address.City       = clientWithAddres.City;
                ctx.SaveChanges();
            }

            return(RedirectToAction("Index", "Clients"));
        }
Beispiel #6
0
        public ActionResult Adding(RequestAddModel requestModel)
        {
            var request = new Request
            {
                Id              = Guid.NewGuid(),
                ClientSymbol    = requestModel.ClientSymbol,
                Description     = requestModel.Description,
                RequestPriority = requestModel.RequestPriority,
                RequestType     = requestModel.RequestType,
                RequestStatus   = RequestStatus.Nowy,
                Date            = DateTime.Now,
            };

            using (var ctx = new ResuestServiceContext())
            {
                ctx.Requests.Add(request);
                ctx.SaveChanges();
            }

            return(RedirectToAction("Index", "Requests"));
        }
Beispiel #7
0
        public ActionResult Adding(EmployeeModel employeeModel)
        {
            if (!ModelState.IsValid)
            {
                return(Add(employeeModel));
            }

            var employee = new Employee
            {
                Identifier = Guid.NewGuid(),
                FirstName  = employeeModel.FirstName,
                LastName   = employeeModel.LastName
            };

            using (var ctx = new ResuestServiceContext())
            {
                ctx.Employees.Add(employee);
                ctx.SaveChanges();
            }

            return(RedirectToAction("Index", "Employees"));
        }