Пример #1
0
 public bool AddParent(string name, string lastName1, string lastName2, DateTime birthday, char genre, string email, string phone)
 {
     try
     {
         var newParent = new Parent()
         {
             Name             = name,
             LastName2        = lastName2,
             LastName1        = lastName1,
             Birthday         = birthday,
             RegistrationDate = DateTime.UtcNow,
             CreateDatetime   = DateTime.UtcNow,
             CreateUser       = "******",
             Address          = "some address that should not be here...",
             Email            = email,
             Phone            = phone,
             CountryId        = "IDIOTA"
         };
         _context.Parents.Add(newParent);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Пример #2
0
 public bool CreateGroup(int clientId, int levelId, int cycleId, string shortName, string min, string max)
 {
     try
     {
         var newGroup = new Group()
         {
             ClientId       = clientId,
             LevelId        = levelId,
             CycleId        = cycleId,
             GroupShortname = shortName,
             MaxDate        = DateTime.Parse(max),
             MinDate        = DateTime.Parse(min),
             CreateDatetime = DateTime.UtcNow,
             CreateUser     = "******",
             GroupStatusId  = 1
         };
         _context.Groups.Add(newGroup);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Пример #3
0
        public ActionResult <IEnumerable <string> > TestDb()
        {
            var dog = "dog";

            using (var context = new Kinder2021Context())
            {
                //add students
                for (int i = 1; i < 15; i++)
                {
                    var student = new Student()
                    {
                        CreateDatetime   = DateTime.UtcNow,
                        Name             = "RandomName_" + i.ToString(),
                        LastName1        = "Lastname1_" + i.ToString(),
                        LastName2        = "Lastname2_" + i.ToString(),
                        Birthday         = Convert.ToDateTime("2016-12-" + i.ToString()),
                        CreateUser       = "******",
                        RegistrationDate = DateTime.UtcNow
                    };
                    context.Students.Add(student);
                }
                context.SaveChanges();
                var students = context.Students.ToList();



                return(new JsonResult(students.Select(c => new { c.Name, c.LastName1 })));
            }
        }
Пример #4
0
 public bool CreateDocument(int clientId, bool isProfilePic, int?studentId, int?teacherId, int?groupId, int?paymentRequestId, string dbPath, string title)
 {
     try
     {
         var newDoc = new Document()
         {
             IsProfilePic     = isProfilePic,
             ClientId         = clientId,
             FileLocation     = dbPath,
             GroupId          = groupId == 0 ? null : groupId,
             StudentId        = studentId == 0 ? null : studentId,
             TeacherId        = teacherId == 0 ? null : teacherId,
             Title            = title,
             PaymentRequestId = paymentRequestId,
             CreateDatetime   = DateTime.UtcNow,
             CreateUser       = "******",
         };
         _context.Documents.Add(newDoc);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Пример #5
0
        public bool CreateStudent(NewPersonDTO request)
        {
            try
            {
                var student = new Student()
                {
                    CreateDatetime = DateTime.UtcNow,
                    Name = request.Name,
                    LastName1 = request.LastName1,
                    LastName2 = request.LastName2,
                    Birthday = Convert.ToDateTime("2018-12-1"),
                    CreateUser = "******",
                    RegistrationDate = DateTime.UtcNow

                };
                _context.Students.Add(student);
                _context.SaveChanges();

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Пример #6
0
 public bool CreatePayment(int requestId, int parentId, decimal amount)
 {
     try
     {
         var newPayment = new Payment()
         {
             Amount           = amount,
             ParentId         = parentId,
             CreateDatetime   = DateTime.UtcNow,
             CreateUser       = "******",
             PaymentRequestId = requestId
         };
         _context.Payments.Add(newPayment);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }