Exemplo n.º 1
0
        public Response Registration(T_Users data)
        {
            Console.WriteLine(data);
            // data.RoleId = 2;
            dalObj.T_Users.Add(data);
            //dalobject.SaveChanges();
            try
            {
                dalObj.SaveChanges();
                response.Data   = data;
                response.Error  = null;
                response.Status = "Success";
                return(response);
            }
            catch (DbEntityValidationException ex)
            {
                //foreach (var entityValidationErrors in ex.EntityValidationErrors)
                //{
                //    foreach (var validationError in entityValidationErrors.ValidationErrors)
                //    {
                //        Console.WriteLine("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                //    }
                //}

                response.Data   = null;
                response.Error  = ex;
                response.Status = "Error";
                return(response);
            }
        }
Exemplo n.º 2
0
 public bool AddRole(T_Roles role)
 {
     try
     {
         dalobj.T_Roles.Add(role);
         dalobj.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 public Response Resgistration([FromBody] T_Users u)
 {
     if (u != null)
     {
         //u.RoleId = 3;
         dalObj.T_Users.Add(u);
         dalObj.SaveChanges();
         response.Error  = null;
         response.Status = "User Register Successfully...";
         return(response);
     }
     else
     {
         response.Error  = null;
         response.Status = "Please enter valid data..";
         return(response);
     }
 }
Exemplo n.º 4
0
 public Response post([FromBody] T_JourneyDetail j)
 {
     if (j != null)
     {
         //j.UserId = 4;
         j.FareperKM = 5;
         j.TotalFare = j.TotalDistance * 5;
         dalobj.T_JourneyDetail.Add(j);
         dalobj.SaveChanges();
         response.Error  = null;
         response.Status = "Successfully";
         return(response);
     }
     else
     {
         response.Error  = null;
         response.Status = "Failed";
         return(response);
     }
 }
Exemplo n.º 5
0
 public bool Save()
 {
     Dbobj.SaveChanges();
     return(true);
 }