示例#1
0
 public CommandResult Delete(LearningFacility command)
 {
     try
     {
         string           result         = "";
         LearningFacility teacherPartner = new LearningFacility();
         Tools.CopyClass(teacherPartner, command);
         var IsExist = unitOfWork.GenericRepositories <LearningFacility>().FindBy(x => x.RecordID == command.RecordID).FirstOrDefault();
         if (IsExist != null)
         {
             unitOfWork.GenericRepositories <LearningFacility>().Delete(teacherPartner);
             result = unitOfWork.SaveChange();
             LogEventStore(teacherPartner.RecordID.ToString(), "LearningFacility", "Delete");
         }
         return(new CommandResult()
         {
             Success = result != "" ? false : true,
             Status = result != "" ? 400 : 200,
             Message = result != "" ? result : "Record Saved successfully.",
             ServerRecordId = teacherPartner.RecordID,
             RecordId = command.RecordID
         });
     }
     catch (Exception ex)
     {
         return(new CommandResult()
         {
             Success = false,
             Status = 400,
             Message = ex.Message,
             RecordId = command.RecordID
         });
     }
 }
示例#2
0
        public CommandResult Save(LearningFacility command)
        {
            try
            {
                string           result         = "";
                LearningFacility teacherProfile = new LearningFacility();
                Tools.CopyClass(teacherProfile, command);
                var IsExist = unitOfWork.GenericRepositories <LearningFacility>().FindBy(x => x.RecordID == command.RecordID).FirstOrDefault();
                if (IsExist == null)
                {
                    teacherProfile.Status = 1;
                    unitOfWork.GenericRepositories <LearningFacility>().Insert(teacherProfile);
                    result = unitOfWork.SaveChange();
                    LogEventStore(teacherProfile.RecordID.ToString(), "TeacherProfile", "Save");
                }
                else
                {
                    teacherProfile.RecordID = IsExist.RecordID;
                    teacherProfile.Status   = 1;

                    unitOfWork.GenericRepositories <LearningFacility>().Update(teacherProfile);
                    result = unitOfWork.SaveChange();
                    LogEventStore(teacherProfile.RecordID.ToString(), "TeacherProfile", "Update");
                }
                return(new CommandResult()
                {
                    Success = result != "" ? false : true,
                    Status = result != "" ? 400 : 200,
                    Message = result != "" ? result : "Record Saved successfully.",
                    ServerRecordId = teacherProfile.RecordID,
                    RecordId = command.RecordID
                });
            }
            catch (Exception ex)
            {
                return(new CommandResult()
                {
                    Success = false,
                    Status = 400,
                    Message = ex.Message,
                    RecordId = command.RecordID
                });
            }
        }