public Object Add()
 {
     try
     {
         if (request.Type == ModelType.User)
         {
             User value = (request as Request <User>).RequestedMembers.First();
             return(new Response <User>(request as Request <User>, users.AddAndSave(value)));
         }
         if (request.Type == ModelType.Role)
         {
             Role value = (request as Request <Role>).RequestedMembers.First();
             return(new Response <Role>(request as Request <Role>, roles.AddAndSave(value)));
         }
         if (request.Type == ModelType.UserRoles)
         {
             UserRoles value = (request as Request <UserRoles>).RequestedMembers.First();
             return(new Response <UserRoles>(request as Request <UserRoles>, userroles.AddAndSave(value)));
         }
     }
     catch
     {
         return(null);
     }
     return(null);
 }
示例#2
0
 public IOperationResult Save(Folder folder)
 {
     try
     {
         if (folder.Id <= 0)
         {
             // create
             return(OperationResult.Succeeded(foldersRepo.AddAndSave(folder)));
         }
         else
         {
             //update
             return(OperationResult.Succeeded(foldersRepo.UpdateAndSave(folder)));
         }
     }
     catch (Exception ex)
     {
         return(OperationResult.NotSucceeded(ex.Message));
     }
 }
示例#3
0
        public IOperationResult SaveAsset(StorageFile file)
        {
            var storedFile = SaveAssetToStorage(file);

            if (storedFile != null)
            {
                // save to db
                var savedAsset = assetsRepo.AddAndSave(new Asset()
                {
                    Name     = storedFile.FileName,
                    Url      = storedFile.FileUrl,
                    Metadata = metadataService.GetMetadata(storedFile.FileStream)
                });

                if (savedAsset != null)
                {
                    return(OperationResult.Succeeded(savedAsset, "Asset Saved"));
                }
            }

            //return OperationResult.NotSucceeded("Asset Not Saved");
            return(OperationResult.NotSucceeded("Asset not Saved"));
        }
 public Object Add()
 {
     try
     {
         if (request.Type == ModelType.Course)
         {
             Course value = (request as Request <Course>).RequestedMembers.First();
             return(new Response <Course>(request as Request <Course>, courses.AddAndSave(value)));
         }
         if (request.Type == ModelType.DegreeProgram)
         {
             DegreeProgram value = (request as Request <DegreeProgram>).RequestedMembers.First();
             return(new Response <DegreeProgram>(request as Request <DegreeProgram>, degreePrograms.AddAndSave(value)));
         }
         if (request.Type == ModelType.ElectiveCourse)
         {
             ElectiveCourse value = (request as Request <ElectiveCourse>).RequestedMembers.First();
             return(new Response <ElectiveCourse>(request as Request <ElectiveCourse>, electiveCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.ElectiveList)
         {
             ElectiveList value = (request as Request <ElectiveList>).RequestedMembers.First();
             return(new Response <ElectiveList>(request as Request <ElectiveList>, electiveLists.AddAndSave(value)));
         }
         if (request.Type == ModelType.ElectiveListCourse)
         {
             ElectiveListCourse value = (request as Request <ElectiveListCourse>).RequestedMembers.First();
             return(new Response <ElectiveListCourse>(request as Request <ElectiveListCourse>, electiveListCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.Plan)
         {
             Plan value = (request as Request <Plan>).RequestedMembers.First();
             return(new Response <Plan>(request as Request <Plan>, plans.AddAndSave(value)));
         }
         if (request.Type == ModelType.PlanCourse)
         {
             PlanCourse value = (request as Request <PlanCourse>).RequestedMembers.First();
             return(new Response <PlanCourse>(request as Request <PlanCourse>, planCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.PrerequisiteCourse)
         {
             PrerequisiteCourse value = (request as Request <PrerequisiteCourse>).RequestedMembers.First();
             return(new Response <PrerequisiteCourse>(request as Request <PrerequisiteCourse>, prerequisiteCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.RequiredCourse)
         {
             RequiredCourse value = (request as Request <RequiredCourse>).RequestedMembers.First();
             return(new Response <RequiredCourse>(request as Request <RequiredCourse>, requiredCourses.AddAndSave(value)));
         }
         if (request.Type == ModelType.Semester)
         {
             Semester value = (request as Request <Semester>).RequestedMembers.First();
             return(new Response <Semester>(request as Request <Semester>, semesters.AddAndSave(value)));
         }
     }
     catch
     {
         return(null);
     }
     return(null);
 }