Пример #1
0
        public async Task <IHttpActionResult> PostAttendee(Att_Attendee attendee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await db.Database
                .ExecuteSqlCommandAsync("EXEC dbo.Att_SaveAttendee @Id, @FirstName, @MiddleName, @LastName, @Gender, @Address, @ZoneId, @CityId, @ImsId, @IsKaryakar, @IsDeleted",
                                        new SqlParameter { ParameterName = "Id", Value = attendee.Id },
                                        new SqlParameter { ParameterName = "FirstName", Value = attendee.FirstName },
                                        new SqlParameter { ParameterName = "MiddleName", Value = string.IsNullOrEmpty(attendee.MiddleName) ? (object)DBNull.Value : attendee.MiddleName },
                                        new SqlParameter { ParameterName = "LastName", Value = attendee.LastName },
                                        new SqlParameter { ParameterName = "Gender", Value = attendee.Gender },
                                        new SqlParameter { ParameterName = "Address", Value = attendee.Address },
                                        new SqlParameter { ParameterName = "ZoneId", Value = attendee.ZoneId },
                                        new SqlParameter { ParameterName = "CityId", Value = attendee.CityId },
                                        new SqlParameter { ParameterName = "ImsId", Value = attendee.ImsId },
                                        new SqlParameter { ParameterName = "IsKaryakar", Value = attendee.IsKaryakar },
                                        new SqlParameter { ParameterName = "IsDeleted", Value = attendee.IsDeleted }
                                        );
            }
            catch (Exception ex)
            {
                throw;
            }

            return(CreatedAtRoute("DefaultApi", new { id = attendee.Id }, attendee));
        }
Пример #2
0
        public async Task <IHttpActionResult> PutAttendee(int id, Att_Attendee attendee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != attendee.Id)
            {
                return(BadRequest());
            }

            try
            {
                await db.Database
                .ExecuteSqlCommandAsync("EXEC dbo.Att_SaveAttendee @Id, @FirstName, @MiddleName, @LastName, @Gender, @Address, @ZoneId, @CityId, @ImsId, @IsKaryakar, @SevaFullNames, @IsDeleted",
                                        new SqlParameter { ParameterName = "Id", Value = attendee.Id },
                                        new SqlParameter { ParameterName = "FirstName", Value = attendee.FirstName },
                                        new SqlParameter { ParameterName = "MiddleName", Value = string.IsNullOrEmpty(attendee.MiddleName) ? (object)DBNull.Value : attendee.MiddleName },
                                        new SqlParameter { ParameterName = "LastName", Value = attendee.LastName },
                                        new SqlParameter { ParameterName = "Gender", Value = attendee.Gender },
                                        new SqlParameter { ParameterName = "Address", Value = attendee.Address },
                                        new SqlParameter { ParameterName = "ZoneId", Value = attendee.ZoneId },
                                        new SqlParameter { ParameterName = "CityId", Value = attendee.CityId },
                                        new SqlParameter { ParameterName = "ImsId", Value = attendee.ImsId },
                                        new SqlParameter { ParameterName = "IsKaryakar", Value = attendee.IsKaryakar },
                                        new SqlParameter { ParameterName = "SevaFullNames", Value = string.IsNullOrEmpty(attendee.SevaFullNames) ? "-->" : attendee.SevaFullNames },
                                        new SqlParameter { ParameterName = "IsDeleted", Value = attendee.IsDeleted }
                                        );
            }
            catch (Exception ex)
            {
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }