public async Task <bool> AddUpdateSessionType(SessionTypeData type)
 {
     try
     {
         return(await this._superAdminRepo.AddUpdateSessionType(type));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
        public async Task <bool> AddUpdateSessionType(SessionTypeData type)
        {
            try
            {
                if (type.TypeId == 0)
                {
                    MasterSessionType sessionType = new MasterSessionType
                    {
                        TypeId       = 0,
                        TypeName     = type.TypeName,
                        IsActive     = true,
                        CreatedDate  = DateTime.UtcNow,
                        ModifiedDate = null,
                        CreatedBy    = type.CreatedBy,
                        ModifiedBy   = null,
                        IsDeleted    = false,
                    };
                    this.therapistContext.MasterSessionType.Add(sessionType);
                    await this.therapistContext.SaveChangesAsync();

                    //return sessionType.TypeId;
                }
                else
                {
                    MasterSessionType updateType = this.therapistContext.MasterSessionType.Where(x => x.TypeId == type.TypeId).FirstOrDefault();
                    updateType.TypeName     = type.TypeName;
                    updateType.ModifiedBy   = type.CreatedBy;
                    updateType.ModifiedDate = DateTime.UtcNow;

                    await this.therapistContext.SaveChangesAsync();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> AddUpdateSessionType([FromBody] SessionTypeData type)
        {
            JsonResponse <bool> objResult = new JsonResponse <bool>();

            try
            {
                bool success = await this._superAdminService.AddUpdateSessionType(type);

                if (success)
                {
                    objResult.Data    = success;
                    objResult.Status  = StaticResource.SuccessStatusCode;
                    objResult.Message = StaticResource.SavedSuccessfulMessage;
                }
            }
            catch (Exception ex)
            {
                HttpContext.RiseError(ex);
                objResult.Data    = false;
                objResult.Status  = StaticResource.FailStatusCode;
                objResult.Message = "Exception occured";
            }
            return(new OkObjectResult(objResult));
        }