Exemplo n.º 1
0
        public Ticket UpdateOldTicket(User u, Ticket t, Company c)
        {
            t = Update(t);
            u.Id = t.User.Id;
            c.Id = t.User.Company.Id;
            c = Update(c);
            u = Update(u);

            u.CompanyId = c.Id;
            u.Company = c;

            t.UserId = u.Id;
            t.User = u;
            entity.SaveChanges();

            return t;
        }
Exemplo n.º 2
0
        private Company Update(Company c)
        {
            var entry = entity.Entry<Company>(c);

            if (entry.State == System.Data.EntityState.Detached)
            {
                var set = entity.Set<Company>();
                Company attachedEntity = entity.Set<Company>().Local.SingleOrDefault(e => e.Id == c.Id);  // You need to have access to key

                if (attachedEntity != null)
                {
                    var attachedEntry = entity.Entry(attachedEntity);
                    attachedEntry.CurrentValues.SetValues(c);
                }
                else
                {
                    entry.State = System.Data.EntityState.Modified; // This should attach entity
                }
                return attachedEntity;
            }
            return c;
        }
Exemplo n.º 3
0
 public Ticket AddNewTicket(User user, Ticket ticket, Company company)
 {
     return _new.AddNewTicket(user, ticket, company);
 }
Exemplo n.º 4
0
 public Ticket UpdateOldTicket(User user, Ticket t, Company company)
 {
     return _old.UpdateOldTicket(user, t, company);
 }
Exemplo n.º 5
0
        private Ticket GetNewData()
        {
            Company c = new Company();
            BE.User u = new BE.User();

            if (Request.Form.Count > 0)
            {
                foreach (string item in Request.Form)
                {
                    if (item.Contains("Company"))
                    {
                        if (item.Contains("Name"))
                        {
                            c.Name = Request[item];
                            continue;
                        }
                        if (item.Contains("Addr"))
                        {
                            c.Address = Request[item];
                            continue;

                        }
                        if (item.Contains("Zip"))
                        {
                            c.Zip = Convert.ToInt32(Request[item]);
                            continue;

                        }
                        if (item.Contains("Mail"))
                        {
                            c.Mail = Request[item];
                            continue;

                        }
                        if (item.Contains("Phone"))
                        {
                            c.Phone = Convert.ToInt32(Request[item]);
                            continue;

                        }
                    }
                    else
                    {
                        if (item.Contains("FirstName"))
                        {
                            u.Firstname = Request[item];
                            continue;

                        }
                        if (item.Contains("LastName"))
                        {
                            u.Lastname = Request[item];
                            continue;

                        }
                        if (item.Contains("Mail"))
                        {
                            u.Mail = Request[item];
                            continue;

                        }
                        if (item.Contains("Phone"))
                        {
                            u.Phone = Convert.ToInt32(Request[item]);
                            continue;
                        }

                    }
                }
            }
            int countIsDone = Request.Form.AllKeys.Where(k => k.Contains("chkIsDone")).Count();
            int countIsDeleted = Request.Form.AllKeys.Where(k => k.Contains("chkIsDeleted")).Count();
            if (countIsDone == 0)
            {
                _tick.IsDone = false;
                _tick.Finished = null;
            }
            else
                _tick.IsDone = true;
            if (countIsDeleted == 0)
                _tick.IsDeleted = false;
            else
                _tick.IsDeleted = true;

            return _bllTicket.UpdateOldTicket(u, _tick, c);
        }