Esempio n. 1
0
 public bool Insert(ClassParam classParam)
 {
     classes.Name       = classParam.Name;
     classes.CreateDate = DateTimeOffset.Now.LocalDateTime;
     myContext.Classes.Add(classes);
     return(saveChange.save());
 }
 public void Post([FromBody] ClassParam newClass)
 {
     _classRespository.AddClass(new Class
     {
         ClassName = newClass.ClassName
     });
 }
Esempio n. 3
0
        public bool Update(string id, ClassParam classParam)
        {
            var get = Get(id);

            get.Name       = classParam.Name;
            get.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            return(saveChange.save());
        }
Esempio n. 4
0
        // POST: api/Classes
        public HttpResponseMessage InsertClass(ClassParam ClassParam)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Wrong Parameter");
            var result  = _iClassService.Insert(ClassParam);

            if (result)
            {
                message = Request.CreateResponse(HttpStatusCode.OK, "Successfully Added");
            }
            return(message);
        }
 public bool Insert(ClassParam classParam)
 {
     if (classParam.Name.ToString() == " ")
     {
         MessageBox.Show("Don't insert white space");
     }
     else
     {
         status = _classRepository.Insert(classParam);
     }
     return(status);
 }
Esempio n. 6
0
 public bool Insert(ClassParam classParam)
 {
     if (classParam == null)
     {
         throw new NullReferenceException();
     }
     else
     {
         status = _classRepository.Insert(classParam);
     }
     return(status);
 }
Esempio n. 7
0
        public bool Update(string id, ClassParam classParam)
        {
            if (id == null)
            {
                throw new NullReferenceException();
            }
            var get = Get(id);

            if (classParam == null)
            {
                throw new NullReferenceException();
            }
            else
            {
                status = _classRepository.Update(id, classParam);
            }
            return(status);
        }
Esempio n. 8
0
        // PUT: api/Classes/5
        public HttpResponseMessage UpdateClass(int id, ClassParam ClassParam)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Bad Request");

            if (string.IsNullOrWhiteSpace(id.ToString()))
            {
                message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Id");
            }
            else
            {
                var get = _iClassService.Update(id.ToString(), ClassParam);
                if (get)
                {
                    message = Request.CreateResponse(HttpStatusCode.OK, get);
                    return(message);
                }
            }
            return(message);
        }
        public bool Update(int?id, ClassParam classParam)
        {
            var   result  = 0;
            Class classes = Get(id);

            classes.Name           = classParam.Name;
            classes.Departments.Id = classParam.Departments.Id;
            classes.Batchs.Id      = classParam.Batchs.Id;
            classes.UpdateDate     = DateTimeOffset.Now.LocalDateTime;
            //_context.Entry(batch).State = System.Data.Entity.EntityState.Modified;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Update Successfully");
                Console.Read();
            }
            return(status);
        }
        public bool Insert(ClassParam classParam)
        {
            var result = 0;

            classes.Name           = classParam.Name;
            classes.Departments.Id = classParam.Departments.Id;
            classes.Batchs.Id      = classParam.Batchs.Id;
            classes.CreateDate     = DateTimeOffset.Now.LocalDateTime;
            _context.Classes.Add(classes);
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Insert Successfully");
            }
            else
            {
                MessageBox.Show("Insert Failed");
            }
            return(status);
        }
 public bool Update(int?id, ClassParam classParam)
 {
     if (_classRepository.Get(id) == null)
     {
         MessageBox.Show("Sorry, your data is not found");
     }
     else if (id.ToString() == " ")
     {
         MessageBox.Show("Don't insert white space in Id");
     }
     else
     {
         if (classParam.Name.ToString() == " ")
         {
             MessageBox.Show("Don't insert white space in Name");
         }
         else
         {
             status = _classRepository.Update(id, classParam);
         }
     }
     return(status);
 }