Exemplo n.º 1
0
        public async Task <IActionResult> PutCalendar(string calendarName, Calendar calendar)
        {
            if (calendarName != calendar.CalendarName)
            {
                return(BadRequest());
            }
            _context.Entry(calendar).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CalendarExists(calendarName))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        // adds a task to the selected day
        public void AddTask(Day day, string taskName, string taskKeyWords, string taskDescription)
        {
            var currentday = SelectDay(day);

            currentday.TaskName        = taskName;
            currentday.TaskKeyWords    = taskKeyWords;
            currentday.TaskDescription = taskDescription;

            context.Entry(currentday).CurrentValues.
            SetValues(context.Days.Where(x => x.date.Equals(currentday.date)));

            this.context.SaveChanges();
        }
        public async Task <IActionResult> PutCustomer(int id, Customer customer)
        {
            if (id != customer.ID)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutTodo(int id, [FromBody] Todo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var list = _context.Lists.FirstOrDefaultAsync(p => p.Id == todo.Id);

            _context.Entry(todo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }

            catch (DbUpdateConcurrencyException)
            {
                if (!TodoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NoContent());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> PutAppointmentType(int id, AppointmentType appointmentType)
        {
            if (id != appointmentType.ID)
            {
                return(BadRequest());
            }

            _context.Entry(appointmentType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppointmentTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 6
0
 public int UpdateAccount(Account account)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Entry(account).State = EntityState.Modified;
         return(ctx.SaveChanges());
     }
 }
Exemplo n.º 7
0
 public int UpdateCurrency(Currency currency)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Entry(currency).State = EntityState.Modified;
         return(ctx.SaveChanges());
     }
 }
Exemplo n.º 8
0
 public int UpdateCardCompany(CardCompany cardCompany)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Entry(cardCompany).State = EntityState.Modified;
         return(ctx.SaveChanges());
     }
 }
Exemplo n.º 9
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Type,Subject,BeginDateTime,EndDateTime,Place,State")] Note note)
        {
            if (note.EndDateTime <= note.BeginDateTime)
            {
                ModelState.AddModelError("BeginDateTime", "Дата начала должна быть меньше даты конца");
            }

            if (ModelState.IsValid)
            {
                db.Entry(note).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(note));
        }
Exemplo n.º 10
0
 public int UpdateMovement(Movement movement)
 {
     using (var ctx = new OrganizerContext())
     {
         ctx.Entry(movement).State = EntityState.Modified;
         return(ctx.SaveChanges());
     }
 }
Exemplo n.º 11
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,FirstName,LastName,Patronymic,BirthDate,Organization,Position")] Contact contact, List <string> phone, List <string> email, List <string> skype, List <string> other)
        {
            if (ModelState.IsValid)
            {
                List <ContactInformation> contactInformations = await db.ContactInformations.Where(c => c.ContactId == contact.Id).ToListAsync();

                foreach (var item in contactInformations)
                {
                    db.ContactInformations.Remove(item);
                }

                db.Entry(contact).State = EntityState.Modified;
                await db.SaveChangesAsync();

                foreach (string item in phone)
                {
                    if (item != null && item != "")
                    {
                        db.ContactInformations.Add(new ContactInformation(item, null, null, null, contact.Id));
                        await db.SaveChangesAsync();
                    }
                }
                foreach (string item in email)
                {
                    if (item != null && item != "")
                    {
                        db.ContactInformations.Add(new ContactInformation(null, item, null, null, contact.Id));
                        await db.SaveChangesAsync();
                    }
                }
                foreach (string item in skype)
                {
                    if (item != null && item != "")
                    {
                        db.ContactInformations.Add(new ContactInformation(null, null, item, null, contact.Id));
                        await db.SaveChangesAsync();
                    }
                }
                foreach (string item in other)
                {
                    if (item != null && item != "")
                    {
                        db.ContactInformations.Add(new ContactInformation(null, null, null, item, contact.Id));
                        await db.SaveChangesAsync();
                    }
                }

                return(RedirectToAction("Index"));
            }
            return(View(contact));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> PutList(int id, [FromBody] List list)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userId = _userManager.GetUserId(User);

            var existinglist = _context.Lists
                               .Include(q => q.Todos)
                               .FirstOrDefault(q => _context.Lists.Any(r => r.Id == id));

            existinglist.IsDone = list.IsDone;
            existinglist.Name   = list.Name;



            _context.Entry(list).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            return(Ok(existinglist));
        }
Exemplo n.º 13
0
 private void DiaryDone(Diaryes diary)
 {
     db.Entry(diary).State = EntityState.Modified;
     diary.DoneStatus      = 1;
     db.SaveChanges();
 }